Question

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!

Was it helpful?

Solution

Like this:

        List<SyndLink> links = entry.getLinks();
        for (SyndLink link : links) {
            System.out.println(link.getType());
        }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top