how to strip namespaces with e4x?

Posted by SorcyCat on Stack Overflow See other posts from Stack Overflow or by SorcyCat
Published on 2010-03-24T21:09:00Z Indexed on 2010/03/25 14:23 UTC
Read the original article Hit count: 466

Filed under:
|
|
|

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

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

I need to verify if the above path into the XML is valid. I tried to do this using eval and E4X.

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

However, my actual xml document has namespaces which are getting in the way. I do not know the namespaces ahead of time or care what they are.

Is there a way to strip all the namespaces out ahead of time? Is there a better way to do this?

Thanks!

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about e4x