Solved

Parse XML

Posted on 2013-11-20
2
220 Views
Last Modified: 2013-11-27
I have to try another angle on this one. I am trying to parse data from NOAA weather web service. I can parse the element conditions - icon

-<conditions-icon type="forecast-NWS" time-layout="k-p12h-n13-1">
<name>Conditions Icon</name>
<icon-link>http://forecast.weather.gov/images/wtf/medium/sct.png</icon-link> <icon-link>http://forecast.weather.gov/images/wtf/medium/nbkn.png</icon-link> <icon-link>http://forecast.weather.gov/images/wtf/medium/bkn.png</icon-link> <icon-link>http://forecast.weather.gov/images/wtf/medium/nshra50.png</icon-link> <icon-link>http://forecast.weather.gov/images/wtf/medium/shra80.png</icon-link> <icon-</conditions-icon>

I set this and then loop through the icon-link element to get the values
xmlDoc.SelectSingleNode("/dwml/data/parameters/conditions-icon[@type='forecast-NWS']")

There is another element im trying to capture but it has a different format. It doesnt have the @type value, which is the way all the other elements I need have? Im trying to get the following values from the following

-<weather time-layout="k-p12h-n13-1">
<name>Weather Type, Coverage, Intensity</name>
<weather-conditions weather-summary="Mostly Sunny"/>
<weather-conditions weather-summary="Mostly Cloudy"/>
<weather-conditions weather-summary="Mostly Cloudy"/>
<weather-conditions weather-summary="Chance Showers"/>
<weather-conditions weather-summary="Showers"/>
</weather>

I tried this but it doesnt give me anything?

xmlDoc.SelectSingleNode("/dwml/data/parameters/weather/weather-conditions")

Ive never done this so Im trying to mimic the same way I do for the conditions-icon element but it doesnt have a type, so Im not sure how to do this....

Bottom line is how do I get the values from the weather element. Im coding this in VB.NET too

I was so psyched when I got this to work but now my boss wants more and I cant figure it out.....PLEASE HELP!!!

Thanks
JK
0
Comment
Question by:jknj72
2 Comments
 
LVL 35

Accepted Solution

by:
Miguel Oz earned 500 total points
ID: 39664162
What exactly is needed from the node?
My educated guess is that you need to query by time-layout:
xmlDoc.SelectSingleNode("/dwml/data/parameters/weather[@time-layout='k-p12h-n13-1']")

Open in new window

Note: You can get time-layout value from the previous node:
 <conditions-icon type="forecast-NWS" [b]time-layout="k-p12h-n13-1"> [/b]

Open in new window

as folllows:
Dim node As XmlNode = xmlDoc.SelectSingleNode("/dwml/data/parameters/conditions-icon[@type='forecast-NWS']");
Dim timelayout As string = node.Attributes["time-layout"].Value;

Open in new window

then use timelayout to fecth the correct weather node.
0
 

Author Closing Comment

by:jknj72
ID: 39681027
close enough...thanks
0

Featured Post

The New “Normal” in Modern Enterprise Operations

DevOps for the modern enterprise offers many benefits — increased agility, productivity, and more, but digital transformation isn’t easy, especially if you’re not addressing the right issues. Register for the webinar to dive into the “new normal” for enterprise modern ops.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question