}
private static MetaDocument createRSSDocument(XMLNode node) throws Exception {
List<XMLNode> children = node.getChildren();
if(children == null) return null;
XML2Bean toBean = XML2Bean.getInstance();
List<XMLNode> itemNodes = null;
MetaDocument document = null;
for(XMLNode child : children) {
if(child.isNode(CHANNEL)) {
if(document == null) document = new MetaDocument();
document.setChannel(toBean.toBean(RSSChannel.class, child));
itemNodes = child.getChildren();
if(itemNodes == null) return document;
for(XMLNode itemNode : itemNodes) {
if(!itemNode.isNode(ITEM)) continue;
RSSItem rssItem = toBean.toBean(RSSItem.class, itemNode);
parseRSSLink(itemNode, rssItem);
document.addItem(rssItem);
}
} else if(child.isNode(FEED)) {
if(document == null) document = new MetaDocument();
document.setChannel(toBean.toBean(FeedItem.class, child));
itemNodes = child.getChildren();
if(itemNodes == null) return document;
for(XMLNode itemNode : itemNodes) {
if(!itemNode.isNode(ENTRY)) continue;
EntryItem entryItem = toBean.toBean(EntryItem.class, itemNode);
parseEntryLink(itemNode, entryItem);
document.addItem(entryItem);
}
} else if(child.isNode(ITEM)) {
if(document == null) document = new MetaDocument();
RSSItem rssItem = toBean.toBean(RSSItem.class, child);
parseRSSLink(child, rssItem);
document.addItem(rssItem);
}
}
return document;