• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

Scanning an RSS feed  RSS feed

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
author and iconoclast
Posts: 24203
43
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't try to scan through the data yourself; use an XML parser.
 
mike pa
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by mike pa:
bad news; i have to scan through it myself.



Why? Is this some kind of homework?
 
mike pa
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
does this mean I instantiated my url object wrong? i'm having one hell of a time finding examples of this.
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!