Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery parsing RSS and namespaced element like <content:encoded>

I am using jQuery to parse an RSS feed. Within each <item> is a namespaced element like <content:encoded> I want to select. How do I select it in jQuery?

$(xml).find('item') works but $(xml).find('item content') does not.
like image 802
Corey Avatar asked Dec 03 '25 00:12

Corey


2 Answers

Are you loading the xml via Ajax? Then, make sure that the server sets the content type as 'text/xml' and not 'text/html'.

Also make sure that the tag name of the element you want is indeed content and not something else (like content:encoded). In that case try:

.find('item content\\:encoded')?

Special characters like : need to be escaped in jQuery selectors.

like image 171
kgiannakakis Avatar answered Dec 05 '25 12:12

kgiannakakis


I realize this thread is fairly old but it is the first one that comes up in google when searching for this with jquery. The easiest way to do the search is with:

.find('[nodeName="content:encoded"]')

Hope that helps someone. I spent the last few hours trying to figure out a simple way to access those tags.

like image 40
Andrew Avatar answered Dec 05 '25 14:12

Andrew



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!