JQuery parsing RSS and named element like <content: encoded>

I am using jQuery to parse an RSS feed. Inside each <item>

is an item with names similar to <content:encoded>

which I want to select. How do I select it in jQuery?

$(xml).find('item') works but $(xml).find('item content') does not.

      

+2


source to share


5 answers


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

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



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

      

Special characters such as: must be escaped in jQuery selectors.

+5


source


I understand this thread is quite old, but it is the first one that comes up on google when searching with jquery. The easiest way to do a search is:

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

      



Hope this helps someone. I've spent the last few hours trying to figure out an easy way to access these tags.

+3


source


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

it works fine in Chrome and some older browsers.

+2


source


This is what I got from searching

JQuery selectors are not impotence, so they only use getElementsByTagName (and not getElementsByTagNameNS) to retrieve elements by their nodeName attribute (not localName and NamespaceURI).

It looks like you need to do it in regular js using document.getElementsByTagNameNS(namespace, tagname)

0


source


.find('item encoded')

      

will work with the "content" (namespace) part.

0


source







All Articles