<ahref="http://maven.apache.org/"title="Built by Maven"class="poweredBy">
<imgclass="poweredBy"alt="Built by Maven"src="../../../images/logos/maven-feather.png"/>
</a>
</div>
</div>
<divid="bodyColumn">
<divid="contentBox">
<divclass="section">
<h2>Rome v0.3 Tutorial, Using Rome to read a syndication feed<aname="Rome_v0.3_Tutorial_Using_Rome_to_read_a_syndication_feed"></a></h2>
<p><b>Software requirements:</b> J2SE 1.4+, JDOM B10 and Rome 0.3.</p>
<p>Rome represents syndication feeds (RSS and Atom) as instances of the com.sun.syndication.synd.SyndFeedI interface. The SyndFeedI interfaces and its properties follow the Java Bean patterns. The default implementations provided with Rome are all lightweight classes.</p>
<p>Rome includes parsers to process syndication feeds into SyndFeedI instances. The SyndFeedInput class handles the parsers using the correct one based on the syndication feed being processed. The developer does not need to worry about selecting the right parser for a syndication feed, the SyndFeedInput will take care of it by peeking at the syndication feed structure. All it takes to read a syndication feed using Rome are the following 2 lines of code:</p>
<p>The first line creates a SyndFeedInput instance that will work with any syndication feed type (RSS and Atom versions). The second line instructs the SyndFeedInput to read the syndication feed from the char based input stream of a URL pointing to the feed. The SyndFeedInput.build() method returns a SyndFeedI instance that can be easily processed.</p>
<p>Obtaining the char based input stream has been simplified in this tutorial, the sample code in the distribution is a little more complex to handle charset encodings properly.</p>
<p>The default SyndFeedI implementation has a detailed and clear toString() implementation. The following line just prints it to the application's output.</p>
<divclass="source">
<pre>
System.out.println(feed);
</pre></div>
<p>Following is the full code for a Java application that reads a syndication feed and prints the SyndFeedI bean to the application's output.</p>