0

我有这段代码来解析 RSS 提要,但由于某种原因,我对 itemDownLink 的捕获从未触发。有人可以解释为什么吗?

 public Channel parse(InputStream is) {

    RootElement root = new RootElement("rss");
    Element chanElement = root.getChild("channel");
    Element chanTitle = chanElement.getChild("title");
    Element chanLink = chanElement.getChild("link");
    Element chanDescription = chanElement.getChild("description");
    Element chanLastBuildDate = chanElement.getChild("lastBuildDate");
    Element chanDocs = chanElement.getChild("docs");
    Element chanLanguage = chanElement.getChild("language");

    Element chanItem = chanElement.getChild("item");
    Element itemTitle = chanItem.getChild("title");
    Element itemDescription = chanItem.getChild("description");
    Element itemLink = chanItem.getChild("link");
    Element itemDate = chanItem.getChild("pubDate");
    Element itemDownLink = chanItem.getChild("feedburner:origEnclosureLink");
}

这是捕手:

        itemDownLink.setEndTextElementListener(new EndTextElementListener() { 
        public void end(String body) {
            item.setDownloadLink(body);
        }
    });
4

1 回答 1

1

您需要使用 getChild 的 2 参数形式并指定 feedburner uri (http://rssnamespace.org/feedburner/ext/1.0)。

Element itemDownLink = chanItem.getChild("http://rssnamespace.org/feedburner/ext/1.0", "origEnclosureLink");
于 2012-05-03T01:56:16.053 回答