【发布时间】:2013-06-27 14:39:23
【问题描述】:
我想问是否可以从RSS中的CDATA标签中解析出标签?
我使用了一个基本的 jquery 函数从 RSS 中获取 JSON 对象,这是我的代码:
$.get("someURL", function(data) {
console.log('InGet');
var $xml = $(data);
$xml.find("item").each(function() {
var $this = $(this),
item = {
title: $this.find("title").text(),
link: $this.find("link").text(),
description: $this.find("description").text(),
pubDate: $this.find("pubDate").text(),
author: $this.find("author").text()
}
});
});
现在我想从描述中的 CDATA 获取 html 标签,但似乎 find() 对 item.description 不起作用。
这是一个简单的 RSS 结构
<item>
<description>
<![CDATA[<img .....> some content<div>...</div>]<br><br> some content]>
</description>
</item>
那么我有什么方法可以解析 CDATA,就像我们对那些 xml 标签所做的那样?
【问题讨论】:
标签: jquery html json xml-parsing rss