0

Im trying to retrieve the RSS feed from new.google.com, Im using working with the top stories feed right now: http://news.google.com/news?ned=us&topic=h&output=rss

I can retrieve and process it right, using: http://pastebin.com/YDNPXyVK

Here is my log of what im getting: http://pastebin.com/a5HRsatX, it seems when there is an apostrophe it stops...

I thank you for any help you can offer me.

Beau Grantham
  • 3,435
  • 5
  • 33
  • 43
arayray
  • 241
  • 6
  • 19

2 Answers2

3

You might want to use the ROME library. Here's an example:

package com.infosys.hanumant.rome;

import java.net.URL;
import java.util.Iterator;

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

/**
 * @author Hanumant Shikhare
 */
public class Reader {

  public static void main(String[] args) throws Exception {

    URL url  = new URL("http://example.com/feed.xml");
    XmlReader reader = null;

    try {
      reader = new XmlReader(url);
      SyndFeed feed = new SyndFeedInput().build(reader);
      System.out.println("Feed Title: "+ feed.getAuthor());

      for (Iterator i = feed.getEntries().iterator(); i.hasNext();) {
        SyndEntry entry = (SyndEntry) i.next();
        System.out.println(entry.getTitle());
      }
    } finally {
      if (reader != null)
        reader.close();
      }
    }
}

The example is copied from here.

Behrang
  • 46,888
  • 25
  • 118
  • 160
0

try using this lib to parse the xml feed, it works great!

marcosbeirigo
  • 11,098
  • 6
  • 39
  • 57