How to remove namespaces using e4x?

I have an arbitrary XML document provided by a url. I also have xpath-like expressions.

var xml = <doc><node1><node2><node3>some value</node3></node2></node1></doc>;
var path = "node1.node2.node3";

I need to check if the above path is really specified in XML. I tried to do this using eval and E4X.

var value = eval("xml."+path);

However, my actual xml document has namespaces that get in the way. I don’t know namespaces ahead of time or care about what they are.

Is there a way to remove all namespaces ahead of time? Is there a better way to do this?

Thank!

+3
source share
1 answer

E4X . , node1.node2.node3 *::node1.*::node2.*::node3, eval , .

+3

Source: https://habr.com/ru/post/1738407/


All Articles