ROME 0.8 解析异常
我正在尝试使用 ROME v0.8 (j2sdk1.4.2_07) 解析 RSS 提要,但无论我使用哪个提要,它总是显示相同的错误。
com.sun.synmination.io.ParsingFeedException:无效的 XML:错误 第 14 行:元素类型“meta”必须由匹配项终止 结束标记“”。
import java.net.URL;
import com.sun.syndication.feed.synd.SyndFeed;
import com.sun.syndication.io.SyndFeedInput;
import com.sun.syndication.io.XmlReader;
public class RssTest {
public static void main(String[] args) {
try {
System.out.println("starting...");
URL feedUrl = new URL("http://www.abc.net.au/news/feed/51120/rss.xml");
SyndFeedInput input = new SyndFeedInput();
SyndFeed feed = input.build(new XmlReader(feedUrl));
System.out.println("Feed Title: " + feed.getTitle());
} catch (Exception ex) {
System.out.println("Error: " + ex.getMessage());
}
}
}
I am trying to parse RSS feeds using ROME v0.8 (j2sdk1.4.2_07) but no matter which feed I use it always says the same error.
com.sun.syndication.io.ParsingFeedException: Invalid XML: Error on
line 14: The element type "meta" must be terminated by the matching
end-tag "".
import java.net.URL;
import com.sun.syndication.feed.synd.SyndFeed;
import com.sun.syndication.io.SyndFeedInput;
import com.sun.syndication.io.XmlReader;
public class RssTest {
public static void main(String[] args) {
try {
System.out.println("starting...");
URL feedUrl = new URL("http://www.abc.net.au/news/feed/51120/rss.xml");
SyndFeedInput input = new SyndFeedInput();
SyndFeed feed = input.build(new XmlReader(feedUrl));
System.out.println("Feed Title: " + feed.getTitle());
} catch (Exception ex) {
System.out.println("Error: " + ex.getMessage());
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的示例中的 URL 看起来像格式良好的 XML,并且不包含任何
meta
标记,因此它应该可以被 rome 解析。未终止的meta
标记听起来像是返回 HTML 页面而不是实际的 feed。您是否可能在需要某些特殊登录的代理服务器后面?The URL from your example looks like well-formed XML and does not contain any
meta
tag, so it should be parseable by rome. An unterminatedmeta
tag makes it sound like something is returning a HTML page instead of the actual feed. Are your perhaps behind a proxy server that requires some special login?使用
InputSource
而不是XmlReader
:Use
InputSource
instead ofXmlReader
: