• Status: Solved
  • Priority: Low
  • Security: Public
  • Views: 75
  • Last Modified:

WUnderground XML VB.net Query

I have to write a program that will parse the following attached file from weather underground. I am not a xml programmer and was wondering if someone could provide a sample to parse this xml file. The schema can be found at https://www.wunderground.com/weather/api/d/docs?d=data/forecast10day&MR=1 

Thanks
wuExample.txt
0
nedavehome
Asked:
nedavehome
1 Solution
 
zc2Commented:
Please look at the following sample:
        Dim doc As XmlDocument = New XmlDocument()
        doc.Load("path to the file.xml")
        Dim forecastday As XmlNode
        Dim forecastdays As XmlNodeList
        forecastdays = doc.SelectNodes("/response/forecast/txt_forecast/forecastdays/forecastday")
        For Each forecastday In forecastdays
            Dim fcttext As XmlNode
            fcttext = forecastday.SelectSingleNode("fcttext")
            Console.WriteLine("Forecast: " + fcttext.InnerText)
        Next

Open in new window

It's convenient to use the methods selectNodes() and selectSingleNode() which accept an XPath expression string.
Please spend some time teaching yourself XPath, it's worth it.
Here is some tutorial: https://www.w3schools.com/xml/xpath_intro.asp
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Tackle projects and never again get stuck behind a technical roadblock.
Join Now