nodejs using cheerio parsing xml returns empty CDATA

Lewfigfoortit

New Member
I am using cheerio in nodejs to parse some rss feeds. I am grabbing all the items putting them into an array. I am using 3 test feeds, all of them have elements for each . In one of the feeds the whole "description" is wrapped as CDATA, and its 'description' property is always empty / undefined. Here is an abbreviated code snippet\[code\]//Open the xml document with cheerio$ = cheerio.load(arrXmlDocs,{ ignoreWhitespace : true, xmlMode : true});//Loop through every item$('item').each(function(i, xmlItem){ //array to hold each item being converted into an array var tempArray = []; //Loop through each child of <item> $(xmlItem).children().each(function(i, xmlItem){ //Get the name tempArray[$(this)[0].name] = $(this).text(); }}\[/code\]As expected the two rss feeds that dont have CDATA give me an array like this\[code\][ [ name: 'name of episode', description:'description of episode', pubdate: 'published date' ], [ name: 'name of episode', description:'description of episode', pubdate: 'published date' ]]\[/code\]and the feed with the CDATA description looks like this\[code\] [ name: 'name of episode', pubdate: 'published date' ],\[/code\]So my question is: Why is cheerio not returning values wrapped in CDATA / how can I make it return those values.
 
Back
Top