Finding an XML node by namespace with jQuery
find, jquery, namespaces, xml
Solution
You can use the attribute-contains jQuery-selector (see here)
xml.find("[nodeName*='x:']")
Problem
We've got an XML file where some nodes are namespaced. Basically the file looks like this: ``` <foo> <bar xmlns:x="http://www.example.com/"> <x:bla foo="bar" /> </bar> </foo> ``` What we want to achieve is that we want to select the `x:bla` node, but unfortunately we don't know in advance the node's name, just its namespace. Hence all we know is basically that it's a `x:*` node. Now, the question is: How do we select this node by using jQuery's `find` method once we have parsed the XML file by using `$.parseXML`? Using `$(xml).find("x\\:bla, bla")` works, but only if I know that the node is called `bla`.