April 18, 2006 8:18 PM   Subscribe

I'm new to C# and XML and want to create an XML parser to display weather data. I've seen XML parsers online that read from an XML file, however the XML weather data I want comes from yahoo.com as http://xml.weather.yahoo.com/forecastrss?p=location

"location" is supposed to be replaced by your zipcode. How can I make this parser work with that link instead of an XML file? Or is there a way in C# to convert the link to an XML file? How can this be done?
posted by deeman to Food & Drink (5 answers total)
You probably want to use the WebRequest class. This article shows exactly what to do.
posted by inkyz at 8:39 PM on April 18, 2006

inkyz's link is right on. You don't need to create an XML parser, all that functionality has already been built into the .NET System.XML classes. Use one of the XmlReader child classes, like XmlTextReader.
posted by Gamblor at 8:51 PM on April 18, 2006

"food & drink" is a bit of a stretch for this question.
posted by Gamblor at 8:54 PM on April 18, 2006

I personally wouldn't use XmlTextReader. Rather, I would use XmlDocument and the Load method. You can specify the URL that you want to use, and it will read in the XML data and parse it all nice and good for you. Then you can do whatever you want with the data. (I would look at things like XmlDocument's SelectSingleNode method to get specific fields out of the data, just as a starting point)
posted by antifuse at 2:03 AM on April 19, 2006

In C# although XmlDocument is easier to use (and I'd get it working with that first) the XPathDocument is faster for read-only XML.
posted by holloway at 3:36 AM on April 19, 2006

« Older Help me prove the existence of this non existent...   |   Contributory Negligence in a hit-and-run Newer »
This thread is closed to new comments.