Solved

Parse XML

Posted on 2013-11-20
2
222 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 36

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

756 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