java - RSS 提要描述返回 '<'

标签 java android rss jsoup rss-reader

我正在尝试从这个提要中解析 RSS 数据:http://fulltextrssfeed.com/feeds.bbci.co.uk/news/rss.xml ,它是使用 FullTextRssFeed 生成的地点。唯一的问题是,当我尝试获取描述时,我收到“<”,其他一切正常!。我尝试使用JSoup有了这个,但我不知道该怎么做。你能建议怎么做吗? 我使用的代码与 this tutorial 中使用的代码相同,但我已经替换了使用的 RSS URL。再次感谢! *Here is my RSS reader in action*

最佳答案

您的问题是因为您的 RSS 提要中的描述包含 html,而不是纯文本。以下是描述内容:

<div><span class="story-date"><span class="date">3 April 2013</span> <span class="time-text">Last updated at</span> <span class="time">23:25 ET</span></span> <p><img src="http://news.bbcimg.co.uk/media/images/66739000/jpg/_66739180_philpotts.jpg" width="464" height="261" alt="Mick and Mairead Philpott, Paul Mosley"/><span class="c2">Mick and Mairead Philpott, and Paul Mosley, will be sentenced on Thursday</span></p> <p class="introduction" id="story_continues_1">A couple convicted of killing six of their children in a house fire in Derby are due to be sentenced later.</p> <p>Mick and Mairead Philpott will reappear at Nottingham Crown Court where they were found guilty of six counts of manslaughter, along with their friend Paul Mosley, on Tuesday.</p> <p>The maximum sentence for the crime is life imprisonment.</p> <p>Mrs Justice Thirlwall was due to pass sentence on Wednesday but needed more time to consider mitigation.</p> <p>The court was told that Philpott, 56, was jailed for seven years in 1978 for attempting to murder a previous girlfriend and given a concurrent five-year sentence for stabbing the woman's mother.</p> <p>In 1991 he received a conditional discharge for assault after he head-butted a colleague</p> <p>And in 2010 he was given a police caution after slapping Mairead and dragging her outside by her hair.</p> <p>When Philpott set fire to his house in Victory Road, Derby, he was also facing trial over a road rage incident in which he punched a motorist in the face.</p> <p>He had admitted common assault in relation to the incident but denied dangerous driving.</p> <span class="cross-head">Rape allegation</span> <p>Police have also confirmed that they intend to "thoroughly" investigate an allegation that Philpott raped a woman several years ago.</p> <p>She made the allegation after the death of Philpott's children, but police decided to wait until the end of the manslaughter trial before investigating the complaint further.</p> <p>On Tuesday the jury returned unanimous manslaughter verdicts on Philpott and Mosley, 46, while Mairead Philpott, 32, was convicted by a majority.</p> <p>Jade Philpott, 10, John, nine, Jack, eight, Jesse, six, and Jayden, five, died on the morning of the fire on 11 May 2012.</p> <p>Mairead Philpott's son from a previous relationship, 13-year-old Duwayne, died later in hospital.</p> </div><img src="http://pixel.quantserve.com/pixel/p-89EKCgBk8MZdE.gif" border="0" height="1" width="1" />

您需要以某种方式更改解析器,使其可以忽略描述中 html 内容中的内容。一旦你得到完整的 html fragment ,你就可以在 WebView 中呈现它。我认为通常在 XML 数据 fragment (如 RSS 提要)中存在其他类型的 XML 内容(在本例中为 HTML)时使用 CDATA。老实说,虽然我不太熟悉它的来龙去脉,但我可能是不正确的。

关于java - RSS 提要描述返回 '<',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15815650/

相关文章:

android - 限制 TextView 的长度

php - 如何发现给定 URL 的 RSS 提要

java - 如何检查spark中的列数据类型

javascript - 是否可以在 Wicket 中进行平滑的页面导航转换?

java - 文件正在重新创建,即使它已经存在

java - 使用状态机解析 wiki 标记

java - 将 addTextChangedListener() 添加到循环中创建的每个 EditText 对象

java - 在我的布局中获取两个宽度为 50/50 的按钮

asp.net - 保护ASP.NET网站中Elmah RSS Feed的安全

php - 在动态 PHP 到 XML 脚本中正确转义 &