本文整理汇总了Java中com.sun.syndication.io.WireFeedOutput.outputJDom方法的典型用法代码示例。如果您正苦于以下问题:Java WireFeedOutput.outputJDom方法的具体用法?Java WireFeedOutput.outputJDom怎么用?Java WireFeedOutput.outputJDom使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.syndication.io.WireFeedOutput
的用法示例。
在下文中一共展示了WireFeedOutput.outputJDom方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseEntry
import com.sun.syndication.io.WireFeedOutput; //导入方法依赖的package包/类
/**
* Parse entry from reader.
*/
public static Entry parseEntry(Reader rd, String baseURI)
throws JDOMException, IOException, IllegalArgumentException, FeedException {
// Parse entry into JDOM tree
SAXBuilder builder = new SAXBuilder();
Document entryDoc = builder.build(rd);
Element fetchedEntryElement = entryDoc.getRootElement();
fetchedEntryElement.detach();
// Put entry into a JDOM document with 'feed' root so that Rome can handle it
Feed feed = new Feed();
feed.setFeedType("atom_1.0");
WireFeedOutput wireFeedOutput = new WireFeedOutput();
Document feedDoc = wireFeedOutput.outputJDom(feed);
feedDoc.getRootElement().addContent(fetchedEntryElement);
if (baseURI != null) {
feedDoc.getRootElement().setAttribute("base", baseURI, Namespace.XML_NAMESPACE);
}
WireFeedInput input = new WireFeedInput();
Feed parsedFeed = (Feed)input.build(feedDoc);
return (Entry)parsedFeed.getEntries().get(0);
}
示例2: serializeEntry
import com.sun.syndication.io.WireFeedOutput; //导入方法依赖的package包/类
/**
* Utility method to serialize an entry to writer.
*/
public static void serializeEntry(Entry entry, Writer writer)
throws IllegalArgumentException, FeedException, IOException {
// Build a feed containing only the entry
List entries = new ArrayList();
entries.add(entry);
Feed feed1 = new Feed();
feed1.setFeedType("atom_1.0");
feed1.setEntries(entries);
// Get Rome to output feed as a JDOM document
WireFeedOutput wireFeedOutput = new WireFeedOutput();
Document feedDoc = wireFeedOutput.outputJDom(feed1);
// Grab entry element from feed and get JDOM to serialize it
Element entryElement= (Element)feedDoc.getRootElement().getChildren().get(0);
XMLOutputter outputter = new XMLOutputter();
outputter.output(entryElement, writer);
}