parse html inside cdata using jquery or javascript

cdata, javascript, jquery

Solution

Chances are your markup is not parsed as XML by jQuery. Try explicitly invoking $.parseXML():

var contentText = $($.parseXML(xml)).find("rss content").text();

Problem

I'm getting a website feed that looks like this ``` <rss...> <title> some title </title> <content> <![CDATA[ <div>this tag is ignored<div> who took the cookie in the cookie jar!? ]]> </content> </rss> ``` I need the entire content of the cdata to be displayed in the html. I'm using jquery 1.9.1 and when I get the content part using `$(xml).find('rss content').text()`, it actually ignores the whole `<div>this tag is ignored<div>` part. Any way to get everything inside the CDATA using javascript or jquery?

Original source