Solved

Parse XML

Posted on 2013-11-20
2
213 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Convert XML to excel12book 5 25
DataGridView Events ? 3 38
Export import database 4 45
C# guarantee sql connection close 6 32
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…
The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

863 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now