0

I am using Rome and SyndEntry(com.sun.syndication.feed.synd.SyndEntry) to retrive "getType" field of URL.

Here is the sample xml feed.

<entry>
  <title>Best Sellers</title>
 <link type="application/atom+xml;profile=opds-catalog;kind=acquisition" 
    href="http://www.feedbooks.com/store/top.atom" rel="http://opds-spec.org
/sort/popular"/>
  <updated>2014-03-27T16:38:38Z</updated>
 <id>http://www.feedbooks.com/books/top.atom?range=week</id>
 <content type="text">All categories</content>
</entry>

I want to get this: link type="application/atom+xml;profile=opds-catalog;kind=acquisition"

I tried with below code:

        SyndEntry entry = getItem( index );
        List<SyndEnclosure> enclosureList = (List<SyndEnclosure>)entry.getEnclosures();
        Log.d("opds", "size:"+enclosureList.size());
        for (SyndEnclosure enclosure : enclosureList) {
            Log.d("opds", enclosure.getType());
        }

But it returns enclosureList.size() is zero. What is the correct way to get the link->Type field? thanks!

manhon
  • 683
  • 7
  • 27

1 Answers1

1

Like this:

        List<SyndLink> links = entry.getLinks();
        for (SyndLink link : links) {
            System.out.println(link.getType());
        }
janih
  • 2,214
  • 2
  • 18
  • 24
  • thanks, it works. but i would like to know more, how can i get entry->title, entry->updated, entry->content, entry->link->rel? thanks. – manhon Apr 02 '14 at 17:04
  • The SyndEntry interface has methods for retrieving those values: [SyndEntry javadoc](http://rometools.github.io/rome/apidocs/com/sun/syndication/feed/synd/SyndEntry.html) – janih Apr 03 '14 at 19:08
  • thanks, i can get title, content, link, if i want to get xxx, is it using org.jdom2.Element? http://stackoverflow.com/questions/22844634/java-using-rome-to-get-entry-summary – manhon Apr 04 '14 at 13:12
  • oh, i found it out, it is getDescription() – manhon Apr 04 '14 at 13:52