1

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());
        }
    }       
}
javanna
  • 59,145
  • 14
  • 144
  • 125

2 Answers2

2

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?

Jörn Horstmann
  • 33,639
  • 11
  • 75
  • 118
  • Thanks for your answer Jorn. Turns out I am behind a proxy server, so sorted that out and everything worked as it should! – Cameron Moses Dec 08 '11 at 04:53
0

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);
Byte Commander
  • 6,506
  • 6
  • 44
  • 71