Reading XML file with VB.NET

ANDerson

New Member
I'm building this web based app which will display weather forecasts for the next 24 hours, I'm reading an XML file with all the data I need in it already. The file however contains all the data in similar tags like this:\[code\]<response> <hourly_forecast> <forecast> <temp> <metric>DATA!</metric> </temp> </forecast> <forecast> <temp> <metric>MORE DATA!</metric> ...\[/code\]As you can see, I have to enter a forecast, go through its children, find the data, and then somehow get back to the point when I can read the next forecast and its data and so on. I'm currently using XMLTextReader to be able to read, and the ReadStartElement and ReadToNextSibling methods to navigate through the file, but using those methods you cannot get back up in the file, you can only get down and in, so in order to read the next temperature I had to use a For loop that makes the program go to the next forecast 'succesfully', but it's become very resource intensive, making way too many calls to the weather API, and even giving out timeout errors. It does work if I save the XML file from the website to the project's directory on my computer, that way it's able to run fine and get all the data quick, however, I will not be able to be saving the XML files once I upload this website to the server.So my question is, how can I extract just the data I need from this online weather XML file, and either display it or save it to a database easily and fast?I'm working with ASP and VB on .NET Framework 3.5.
 
Back
Top