Kevin Whinnery
jQuery, XML Parsing, and XML Namespaces

I recently ran into a fun problem as I was using jQuery to parse an XML document that contained namespaced nodes. I first tried something along these lines: $(xmlDoc).find("namespace:tag").text();.

FAIL. This shouldn’t work since : is a special character in jQuery selectors. So as per the instructions in the Selectors documentation, I escaped the colon in the tag name: $(xmlDoc).find("namespace\\:tag").text();.

FAIL. Using jQuery 1.3.x, this fails in all WebKit browsers. WTF? After some Googling, I figured out a round-about way to get at this tag using an attribute filter for nodeName:

Attribute filters, FTW! Hopefully if you find this post first, it will save you some time.