Last Updated: February 25, 2016
·
763
· voiddragon

XML Parsing in Javascript with jQuery

So I had to parse a RSS feed in a pure front-end javascript application.

Then I hit a snag, one of the tags was

<dc:publisher></dc:publisher>

So I tried

$(rss).find('publisher')

Works in Chrome, but not in IE

$(rss).find('dc\\:publisher') 

Works in IE but not in Chrome

Then, after a ton of googling with nodeNames and getElementsByTagName all not working. I realised..that jQuery uses css selectors.

And the really simple solution to this was

$(rss).find('dc\\:publisher, publisher')

And now it works in both.