@Test public void testAtomParser() throws Exception { try (InputStream input = FeedParserTest.class.getResourceAsStream( "/test-documents/testATOM.atom")) { Metadata metadata = new Metadata(); ContentHandler handler = new BodyContentHandler(); ParseContext context = new ParseContext(); new FeedParser().parse(input, handler, metadata, context); String content = handler.toString(); assertFalse(content == null); assertEquals("Sample Atom File for Junit test", metadata.get(TikaCoreProperties.DESCRIPTION)); assertEquals("Test Atom Feed", metadata.get(TikaCoreProperties.TITLE)); } }
public void parse( InputStream stream, ContentHandler handler, Metadata metadata, ParseContext context) throws IOException, SAXException, TikaException { try { SyndFeed feed = new SyndFeedInput().build( new InputSource(new CloseShieldInputStream(stream))); String title = stripTags(feed.getTitleEx()); String description = stripTags(feed.getDescriptionEx()); metadata.set(TikaCoreProperties.TITLE, title); metadata.set(TikaCoreProperties.DESCRIPTION, description); XHTMLContentHandler xhtml = new XHTMLContentHandler(handler, metadata); xhtml.startDocument(); xhtml.element("h1", title); xhtml.element("p", description); xhtml.startElement("ul"); for (Object e : feed.getEntries()) { SyndEntry entry = (SyndEntry) e; String link = entry.getLink(); if (link != null) { xhtml.startElement("li"); xhtml.startElement("a", "href", link); xhtml.characters(stripTags(entry.getTitleEx())); xhtml.endElement("a"); SyndContent content = entry.getDescription(); if (content != null) { xhtml.newline(); xhtml.characters(stripTags(content)); } xhtml.endElement("li"); } } xhtml.endElement("ul"); xhtml.endDocument(); } catch (FeedException e) { throw new TikaException("RSS parse error", e); } }
FeedParser extends AbstractParser { public void parse( InputStream stream, ContentHandler handler, Metadata metadata, ParseContext context) throws IOException, SAXException, TikaException { try { SyndFeed feed = new SyndFeedInput().build( new InputSource(new CloseShieldInputStream(stream))); String title = stripTags(feed.getTitleEx()); String description = stripTags(feed.getDescriptionEx()); metadata.set(TikaCoreProperties.TITLE, title); metadata.set(TikaCoreProperties.DESCRIPTION, description); XHTMLContentHandler xhtml = new XHTMLContentHandler(handler, metadata); xhtml.startDocument(); xhtml.element("h1", title); xhtml.element("p", description); xhtml.startElement("ul"); for (Object e : feed.getEntries()) { SyndEntry entry = (SyndEntry) e; String link = entry.getLink(); if (link != null) { xhtml.startElement("li"); xhtml.startElement("a", "href", link); xhtml.characters(stripTags(entry.getTitleEx())); xhtml.endElement("a"); SyndContent content = entry.getDescription(); if (content != null) { xhtml.newline(); xhtml.characters(stripTags(content)); } xhtml.endElement("li"); } } xhtml.endElement("ul"); xhtml.endDocument(); } catch (FeedException e) { throw new TikaException("RSS parse error", e); } } }
FeedParser extends AbstractParser { public void parse( InputStream stream, ContentHandler handler, Metadata metadata, ParseContext context) throws IOException, SAXException, TikaException { try { SyndFeed feed = new SyndFeedInput().build( new InputSource(new CloseShieldInputStream(stream))); String title = stripTags(feed.getTitleEx()); String description = stripTags(feed.getDescriptionEx()); metadata.set(TikaCoreProperties.TITLE, title); metadata.set(TikaCoreProperties.DESCRIPTION, description); XHTMLContentHandler xhtml = new XHTMLContentHandler(handler, metadata); xhtml.startDocument(); xhtml.element("h1", title); xhtml.element("p", description); xhtml.startElement("ul"); for (Object e : feed.getEntries()) { SyndEntry entry = (SyndEntry) e; String link = entry.getLink(); if (link != null) { xhtml.startElement("li"); xhtml.startElement("a", "href", link); xhtml.characters(stripTags(entry.getTitleEx())); xhtml.endElement("a"); SyndContent content = entry.getDescription(); if (content != null) { xhtml.newline(); xhtml.characters(stripTags(content)); } xhtml.endElement("li"); } } xhtml.endElement("ul"); xhtml.endDocument(); } catch (FeedException e) { throw new TikaException("RSS parse error", e); } }  }
FeedParser extends AbstractParser { public void parse( InputStream stream, ContentHandler handler, Metadata metadata, ParseContext context) throws IOException, SAXException, TikaException { try { SyndFeed feed = new SyndFeedInput().build( new InputSource(new CloseShieldInputStream(stream))); String title = stripTags(feed.getTitleEx()); String description = stripTags(feed.getDescriptionEx()); metadata.set(TikaCoreProperties.TITLE, title); metadata.set(TikaCoreProperties.DESCRIPTION, description); XHTMLContentHandler xhtml = new XHTMLContentHandler(handler, metadata); xhtml.startDocument(); xhtml.element("h1", title); xhtml.element("p", description); xhtml.startElement("ul"); for (Object e : feed.getEntries()) { SyndEntry entry = (SyndEntry) e; String link = entry.getLink(); if (link != null) { xhtml.startElement("li"); xhtml.startElement("a", "href", link); xhtml.characters(stripTags(entry.getTitleEx())); xhtml.endElement("a"); SyndContent content = entry.getDescription(); if (content != null) { xhtml.newline(); xhtml.characters(stripTags(content)); } xhtml.endElement("li"); } } xhtml.endElement("ul"); xhtml.endDocument(); } catch (FeedException e) { throw new TikaException("RSS parse error", e); } }  Set<MediaType> getSupportedTypes(ParseContext context); void parse(
            InputStream stream, ContentHandler handler,
            Metadata metadata, ParseContext context); }
FeedParser extends AbstractParser { public void parse( InputStream stream, ContentHandler handler, Metadata metadata, ParseContext context) throws IOException, SAXException, TikaException { try { SyndFeed feed = new SyndFeedInput().build( new InputSource(new CloseShieldInputStream(stream))); String title = stripTags(feed.getTitleEx()); String description = stripTags(feed.getDescriptionEx()); metadata.set(TikaCoreProperties.TITLE, title); metadata.set(TikaCoreProperties.DESCRIPTION, description); XHTMLContentHandler xhtml = new XHTMLContentHandler(handler, metadata); xhtml.startDocument(); xhtml.element("h1", title); xhtml.element("p", description); xhtml.startElement("ul"); for (Object e : feed.getEntries()) { SyndEntry entry = (SyndEntry) e; String link = entry.getLink(); if (link != null) { xhtml.startElement("li"); xhtml.startElement("a", "href", link); xhtml.characters(stripTags(entry.getTitleEx())); xhtml.endElement("a"); SyndContent content = entry.getDescription(); if (content != null) { xhtml.newline(); xhtml.characters(stripTags(content)); } xhtml.endElement("li"); } } xhtml.endElement("ul"); xhtml.endDocument(); } catch (FeedException e) { throw new TikaException("RSS parse error", e); } }  Set<MediaType> getSupportedTypes(ParseContext context); void parse(
            InputStream stream, ContentHandler handler,
            Metadata metadata, ParseContext context);  }