wood burning stoves 2.0*
The moose likes Java in General and the fly likes Scanning an RSS feed Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Scanning an RSS feed" Watch "Scanning an RSS feed" New topic
Author

Scanning an RSS feed

mike pa
Greenhorn

Joined: Oct 16, 2006
Posts: 8
Somehow I have to scan an RSS feed. Sounds simple enough using a scanner. But then I have to break that feed down into 15 different objects. More specifically, I have to use slashdot.org's news feed and make 15 news objects out of them. Thats not all I have to do but before I get into the rest of the project I need to know how to do this. Thanks
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Don't try to scan through the data yourself; use an XML parser.


[Jess in Action][AskingGoodQuestions]
mike pa
Greenhorn

Joined: Oct 16, 2006
Posts: 8
bad news; i have to scan through it myself. basically i'm going to try and run a loop that will scan each line until it finds a line containing the tags of the information I need.
mike pa
Greenhorn

Joined: Oct 16, 2006
Posts: 8
i believe i got the basic code down to do what i need to do. however, i have an error in my scanner declaration. here's what i have:

Scanner scan = new Scanner(http://slashdot.org/index.rss);

i just guessed as to how to do this and cannot find the proper code anywhere.


don't you just love professors that make you do things that he doesnt teach and aren't in the book?
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Originally posted by mike pa:
bad news; i have to scan through it myself.


Why? Is this some kind of homework?


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
mike pa
Greenhorn

Joined: Oct 16, 2006
Posts: 8
project for school

i created a new url object
URL url = new URL("http://www.slashdot.org/index.rss");
and tried saying
Scanner scan = new Scanner(url);

i imported the java.net.URL package but still get an error. my instructor said make sure i'm importing the proper package, which i believe i am. the error i'm getting says
Driver.java:16: cannot find symbol
symbol : constructor Scanner(java.net.URL)
location: class java.util.Scanner
Scanner scan = new Scanner(url)
^

all other examples i see use a buffered reader or something of the sort but that is not something we have learned in class (but then again, neither is most of the project).
[ October 29, 2006: Message edited by: mike pa ]
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
The compiler is telling you that it *did* find the class, but that it didn't find a constructor taking a URL as parameter.
mike pa
Greenhorn

Joined: Oct 16, 2006
Posts: 8
does this mean I instantiated my url object wrong? i'm having one hell of a time finding examples of this.
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
No, it means you're instantiating the Scanner incorrectly. You need to look at the API for Scanner to see what constructors actually exist that you can use. There isn't one for URL. Note that the URL class has a method that returns an InputStream, and Scanner has a constructor that can accept an InputStream. So there's at least one way to bridge the gap between what you have (URL) and what you need (Scanner).
[ October 30, 2006: Message edited by: Jim Yingst ]

"I'm not back." - Bill Harding, Twister
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Scanning an RSS feed