How to use jQuery for XML parsing with namespaces How to use jQuery for XML parsing with namespaces xml xml

How to use jQuery for XML parsing with namespaces


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]")


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()


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"]')