0

我从我的 Android 应用程序中的 Facebook 页面获取 RSS 提要。

我用来获取信息的 URL 如下: https://www.facebook.com/feeds/page.php?format=rss20&id=100407896713917

但是,例如,当这个 RSS 提要有图像时,它会返回一些 HTML 标记。对我来说,图像并不重要,我只想获得文本内容。

是否可以忽略此 HTML 标签并仅获取文本?

另一个问题,一些特殊字符正在转换为其他字符..但我想在下载信息时没有问题,因为如果我在浏览器中打开上面的 URL,这些奇怪的字符也会出现。

有没有办法将奇怪的字符转换为正常字符?:)

4

1 回答 1

1

我最终做了一个更机械的逻辑。不知道是否有更好的解决方案,但我所做的是根据其代码转换每个字符(我不知道 RSS 用于特殊字符的代码类型)。这是我的逻辑

html = i.getDescription(); // some tag of rss feed
html = html.replaceAll("<(.*?)\\>"," ");//Removes all items in brackets
html = html.replaceAll("<(.*?)\\\n"," ");//Must be undeneath
html = html.replaceFirst("(.*?)\\>", " ");//Removes any connected item to the last bracket
html = html.replaceAll("&nbsp;"," ");
html = html.replaceAll("&amp;"," ");
html = html.replaceAll("&quot;","'");
html = html.replaceAll("&#xe7;","ç");
html = html.replaceAll("&#xe3;","ã");
html = html.replaceAll("&#xf3;","ó");
html = html.replaceAll("&#xe1;","á");
html = html.replaceAll("&#xe9;","é");
html = html.replaceAll("&#xed;","í");
html = html.replaceAll("&#xea;","ê");
html = html.replaceAll("&#xc9;","É");

有了这个逻辑,我也删除了 HTML 标签

于 2013-07-27T00:57:14.960 回答