javaparsingfeedrome

Java SyndFeedInput parse feed


I want to parse non-standard feed using SyndFeedInput

<entry>
<title>4 - Fleetmatics Group plc (0001526160) (Issuer)</title>
<link rel="alternate" type="text/html" href="http://www.sec.gov/Archives/edgar/data/1526160/000120919116115415/0001209191-16-115415-index.htm"/>
<summary type="html">
 &lt;b&gt;Filed:&lt;/b&gt; 2016-04-22 &lt;b&gt;AccNo:&lt;/b&gt; 0001209191-16-115415 &lt;b&gt;Size:&lt;/b&gt; 13 KB
</summary>
<updated>2016-04-22T21:07:34-04:00</updated>
<category scheme="http://www.sec.gov/" label="form type" term="4"/>
<id>urn:tag:sec.gov,2008:accession-number=0001209191-16-115415</id>
</entry>

I can get title, link and updated. But don't know how to get summary and term in category.

while (itEntries.hasNext()) {
            SyndEntry entry = (SyndEntry) itEntries.next();
            String title = StringEscapeUtils.unescapeHtml3(entry.getTitle());
            String link = entry.getLink();
            Date datetime = entry.getUpdatedDate();
            //Module summary = entry.getModule("summary");
            System.out.println(title);
            System.out.println(link);
            System.out.println(datetime);

}

Please advice!


Solution

  • Categories you can access by looping entry.getCategories() and summary is mapped to entry.getDescription():

    SyndFeed feed = ..
    for (SyndEntry entry : feed.getEntries()) {
        for (SyndCategory category : entry.getCategories()) {
            System.out.println(category.getName()); // term
        }
    
        SyndContent summary = entry.getDescription();
        System.out.println(summary.getValue());
    }