Solved

Parse XML

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

Industry Leaders: 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

Suggested Solutions

Title # Comments Views Activity
How to force output to ascii 2 58
SSIS GUID Variable 2 56
Office 365: Assigning MailboxPlan to a mailbox 8 66
vb.net application has warrnings about VB6 calls. 2 42
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
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…

738 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