[英]How to retrieve data from tag <content:encoded> with CDATA from RSS feed with Jsoup for android?
I want to retrieve data from an RSS feed using jsoup.我想使用 jsoup 从 RSS 提要中检索数据。 I am able in all tag but I can't do It when there is content:encoded tag.
我可以使用所有标签,但是当有 content:encoded 标签时我不能这样做。 please anyone help me how to get data from content:encoded tag.
请任何人帮助我如何从内容获取数据:编码标签。 My feed URL is https://sambad.in/feed/ and my code is as well Document doc = Jsoup.parse(String.valueOf(response));
我的提要 URL 是https://sambad.in/feed/我的代码也是 Document doc = Jsoup.parse(String.valueOf(response)); Elements itemElements = doc.select("item");
元素 itemElements = doc.select("item");
for (int i = 0; i < itemElements.size(); i++) {
Element item = itemElements.get(i);
String title = item.child(0).text();
String link=item.child(1).text();
String imgUrl=extractImageUrl(item.select("description").text());
String description = extractPostText(item.select("description").text())+"From Sambad: By Pin2";
String fullnews=extractPostText(item.children().select("http://purl.org/rss/1.0/modules/content/encoded").text());
The selector to use will be content|encoded
.要使用的选择器将是
content|encoded
。 To specify a namespaced tag, replace the :
with a |
要指定命名空间标记,请将
:
替换为|
. . See the jsoup selector documentation for more examples.
有关更多示例,请参阅jsoup 选择器文档。
Here is a live example on Try Jsoup .这是Try Jsoup上的一个活生生的例子。
A couple points to note:有几点需要注意:
content|encoded
selector will be a set of Elements containing text with HTML tags (not parsed HTML elements). content|encoded
选择器的结果将是一组包含带有 HTML 标记的文本的元素(未解析的 HTML 元素)。 That's because the content in the RSS is HTML encoded (escaped).
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.