Solved

Parse XML

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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

707 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

12 Experts available now in Live!

Get 1:1 Help Now