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.
Written by Gerald Goh
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Chrome
Authors
Did you know?
JavaScript on a page runs with the privileges of that origin. One altered library, tag manager, or snippet can read inputs, change what people see, and call your APIs as the user.
Security insights from Cside
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#