Ok Так что я смотрел на это: Using jQuery to extract CDATA in XML for use as HTML contentУдаление CDATA из XML/RSS-канал с помощью JQuery
Но это не помогло то, что я делаю. Я получаю канал rss/xml с URL-адреса. У меня проблема с CDATA в теге title и description. Вот пункт подачи:
<item>
<title><![CDATA[Impact South Africa (Girls)]]></title>
<link>http://www.thriveafricastore.com/products.php?product=Impact-South-Africa-%28Girls%29</link>
<pubDate>Mon, 29 Mar 2010 19:02:26 +0000</pubDate>
<guid isPermaLink="false">http://www.thriveafricastore.com/products.php?product=Impact-South-Africa-%28Girls%29</guid>
<description><![CDATA[<div style='float: right; padding: 10px;'><a href="http://www.thriveafricastore.com/products.php?product=Impact-South-Africa-%28Girls%29" ><img src="http://www.thriveafricastore.com/product_images/t/266/girls__27047_thumb.jpg" alt="" /></a></div><p><strong>You can help us impact South Africa. Do something!<br /></strong></p>
<p>Your basic jersey tee, only better! Made just for women, it contours to your shape and always looks flattering and chic even with a simple pair of jeans. This is one t-shirt you'll want to stock pile. Pre-shrunk 1..<p><strong>Price: <span class="SalePrice">$10.00</span></strong> </p>]]></description>
<content:encoded><![CDATA[<div style='float: right; padding: 10px;'><a href="http://www.thriveafricastore.com/products.php?product=Impact-South-Africa-%28Girls%29" ><img src="http://www.thriveafricastore.com/product_images/t/266/girls__27047_thumb.jpg" alt="" /></a></div><p><strong>You can help us impact South Africa. Do something!<br /></strong></p>
<p>Your basic jersey tee, only better! Made just for women, it contours to your shape and always looks flattering and chic even with a simple pair of jeans. This is one t-shirt you'll want to stock pile. Pre-shrunk 1..<p><strong>Price: <span class="SalePrice">$10.00</span></strong> </p>]]></content:encoded>
</item>
И вот в JQuery я до сих пор:
$.get('http://www.thriveafricastore.com/rss.php?type=xml', {}, function(d) {
$('body').append('New Thrive Store Items');
$('body').append('<div>');
$('item', d).each(function() {
var $item = $(this);
var title = $item.find('title');
var description = $item.find('description').text();
var link = $item.find('link');
var html = '<h3><a href="' + link + '">' + title + '</a></h3>';
$('div').append($(html));
});
}, 'xml');
Любые идеи о моей следующей остановке, чтобы извлекать тег CDATA, так что я могу просто вытащить содержимое из?
Большое спасибо!
Yup. Вот и все :) Jquery всегда указывает на узлы, поэтому вам нужно получить доступ к тексту, если вы хотите с ним справиться! –