Extracting CDATA Using jQuery
- by George L Smyth
It looks like this has been asked before, but the answers do not appear to work for me. I am outputting information from a local XML file, but the description elements is not being output because it is enclosed in CDATA - if I remove the CDATA portion then things work fine.
Here is my code:
$(document).ready(
function() {
$.get('test.xml',
function($info) {
objInfo = $($info);
objInfo.find('item').slice(0,5).each(
function() {
var Guid = $(this).find('guid').text();
var Title = $(this).find('title').text();
var Description = $(this).find('description').text();
$('#Content').append(
"<p><a href='" + Guid + "'>" +
Title + "</a> " +
Description +
"</p>"
)
}
);
},
'xml'
);
}
)
Any idea how I can successfully extract Description information that is wrapped in CDATA?
Thanks -
george