0
RSS에서 CDATA 태그의 태그를 구문 분석 할 수 있는지 묻고 싶습니다.RSS CDATA에서 HTML 태그 구문 분석
나는 여기에 내 코드는 RSS에서 JSON 개체를 얻을 수있는 기본 JQuery와 기능을 사용하고 있습니다 :
$.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 태그를 얻을 싶어하지만 찾을 것()가 item.description에 작동하지 않습니다. 여기
는 RSS 그래서<item>
<description>
<![CDATA[<img .....> some content<div>...</div>]<br><br> some content]>
</description>
</item>
에 대한 간단한 구조는 우리가 그 XML 태그 정상적인 방법을했던 것처럼 나는 CDATA을 구문 분석 할 수있는 방법이다?
그러면 일반 jquery 객체가 반환됩니까? description : $ ($ this.find ("description"). text()). find ("some tag")가 나를 위해 작동하지 않는 것 같습니다 – user1787096
''에 CDATA가 포함되어 있으면'$ this.find ("description"). text()'는 실제 텍스트 즉 HTML 문자열을 반환합니다. jQuery에 전달하여 구문 분석 할 수 있습니다. 'console.log ($ this.find ("description"). text())'는 무엇을 출력합니까? –
Tomalak
물론'$ xml = $ .parseXML (data)'([docs] (http://api.jquery.com/jQuery.parseXML/))을 사용해야합니다. 나는 그것을 놓쳤다. – Tomalak