【发布时间】:2013-02-04 08:15:32
【问题描述】:
我得到一个类似这样的网站供稿
<rss...>
<title> some title </title>
<content>
<![CDATA[ <div>this tag is ignored<div> who took the cookie in the cookie jar!? ]]>
</content>
</rss>
我需要将 cdata 的全部内容显示在 html 中。我正在使用 jquery 1.9.1,当我使用 $(xml).find('rss content').text() 获取内容部分时,
它实际上忽略了整个<div>this tag is ignored<div> 部分。有什么方法可以使用 javascript 或 jquery 获取 CDATA 中的所有内容?
【问题讨论】:
-
CDATA 旨在对解析器隐藏数据,因此不会将其作为 HTML 解析到 DOM 中。我试图了解为什么您的 html 隐藏在 CDATA 中?你能把它 ajax 放进去吗?
-
你试过用
html()代替text()吗?
标签: javascript jquery cdata