This Confluence has been LDAP enabled, if you are an ASF Committer, please use your LDAP Credentials to login. Any problems file an INFRA jira ticket please.

Child pages
  • Creating and Consuming Atom Documents

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The two most common uses for Abdera are creating and parsing Atom documents.

Parsing an Atom Document and printing entry titles

Minimal Required Maven dependency for both examples:

Code Block
xml
xml
<dependency>
    <groupId>org.apache.abdera</groupId>
    <artifactId>abdera-parser</artifactId>
    <version>1.1.1</version>  
</dependency>

Parsing an Atom Document and printing entry titles

Example Code:

Code Block
borderStylesolid
Abdera abdera = new Abdera();
Parser parser = abdera.getParser();
    	    
URL url = new URL("http://intertwingly.net/blog/index.atom");
Document<Feed> doc = parser.parse(url.openStream(),url.toString());
Feed feed = doc.getRoot();
System.out.println(feed.getTitle());
for (Entry entry : feed.getEntries()) {
  System.out.println("\t" + entry.getTitle());
}
System.out.println (feed.getAuthor());

Creating

...

an Atom Document and adding an entry

Code Block
borderStylesolid
  Abdera abdera = new Abdera();
Feed feed = abdera.newFeed();

feed.setId("tag:example.org,2007:/foo");
feed.setTitle("Test Feed");
feed.setSubtitle("Feed subtitle");
feed.setUpdated(new Date());
feed.addAuthor("James Snell");
feed.addLink("http://example.com");
feed.addLink("http://example.com/foo","self");

Entry entry = feed.addEntry();
entry.setId("tag:example.org,2007:/foo/entries/1");
entry.setTitle("Entry title");
entry.setSummaryAsHtml("<p>This is the entry title</p>");
entry.setUpdated(new Date());
entry.setPublished(new Date());
entry.addLink("http://example.com/foo/entries/1");

...