Cameron Moses
Cameron Moses

Reputation: 11

ROME 0.8 Parse Exception

I am trying to parse RSS feeds using ROME v0.8 (j2sdk1.4.2_07) but no matter which feed I use it always says the same error.

com.sun.syndication.io.ParsingFeedException: Invalid XML: Error on line 14: The element type "meta" must be terminated by the matching end-tag "".

import java.net.URL;

import com.sun.syndication.feed.synd.SyndFeed;
import com.sun.syndication.io.SyndFeedInput;
import com.sun.syndication.io.XmlReader;

public class RssTest {

    public static void main(String[] args) {

    try {

            System.out.println("starting...");
            URL feedUrl = new URL("http://www.abc.net.au/news/feed/51120/rss.xml");
            SyndFeedInput input = new SyndFeedInput();
            SyndFeed feed = input.build(new XmlReader(feedUrl));

            System.out.println("Feed Title: " + feed.getTitle());

        } catch (Exception ex) {
            System.out.println("Error: " + ex.getMessage());
        }
    }       
}

Upvotes: 1

Views: 908

Answers (2)

Wilde Shaw
Wilde Shaw

Reputation: 1

Use InputSource instead of XmlReader:

HttpURLConnection connection = (HttpURLConnection)url.openConnection();
InputStream is = connection.getInputStream();
InputSource source = new InputSource(is);
SyndFeedInput input = new SyndFeedInput();
feed = input.build(source);

Upvotes: 0

Jörn Horstmann
Jörn Horstmann

Reputation: 34034

The URL from your example looks like well-formed XML and does not contain any meta tag, so it should be parseable by rome. An unterminated meta tag makes it sound like something is returning a HTML page instead of the actual feed. Are your perhaps behind a proxy server that requires some special login?

Upvotes: 2

Related Questions