How to use jQuery for XML parsing with namespaces
If you are using jquery 1.5 you will have to add quotes around the node selector attribute value to make it work:
.find('[nodeName="z:row"]')
Although the above answer seems to be correct, it does not work in webkit browsers (Safari, Chrome). A better solution I believe would be:
.find("[nodeName=z:myRow, myRow]")
I have spent several hours on this reading about plugins and all sorts of solutions with no luck.
ArnisAndy posted a link to a jQuery discussion, where this answer is offered and I can confirm that this works for me in Chrome(v18.0), FireFox(v11.0), IE(v9.08) and Safari (v5.1.5) using jQuery (v1.7.2).
I am trying to scrape a WordPress feed where content is named <content:encoded> and this is what worked for me:
content: $this.find("content\\:encoded, encoded").text()
I got it.
Turns out that it requires \\
to escape the colon.
$.get(xmlPath, {}, function(xml) {
$("rs\\:data", xml).find("z\\:row").each(function(i) {
alert("found zrow");
});
}, "xml");
As Rich pointed out:
The better solution does not require escaping and works on all "modern" browsers:
.find("[nodeName=z:row]")