By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,419 Members | 1,446 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,419 IT Pros & Developers. It's quick & easy.

XML Soap Client Question

P: n/a
Hello all,
I'm a complete newbie looking for a little advice. I am writing a Soap
Client to request weather data from the NOAA website.
(http://www.nws.noaa.gov/forecasts/xml/) and the response to the sent
request is returned in the form of a string. I know I have to use
something like XmlDocument/XmlNode to extract the text from the Xml
tags, but I'm having problems in doing in. Here's what I'm doing:
__________________________________________________ _____________________

private ndfdXML weatherXML = null;
private XmlDocument doc;
private XmlNode rootNode;
private XmlNodeList wList;
private DateTime startDataTime;
......

weatherXML = new ndfdXML(); //create proxy
startDateTime = new DateTime(2005, 2, 4, 9, 15, 0);

String wStr;
XmlNode nextNode;

wStr = weatherXML.NDFDgenByDay(39, -77, startDateTime, "1",

gov.weather.formatType.Item24hourly);

//Append the XML document to the main window
doc = new XmlDocument();
doc.LoadXml(wStr);

rootNode = doc.DocumentElement.FirstChild;

int j;

if (rootNode.HasChildNodes)
{

for (j=0; j<rootNode.ChildNodes.Count; j++)
{
nextNode = rootNode.NextSibling;
WeatherBox.AppendText(nextNode.InnerText + "\n");
}
}
Nov 16 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
A,

You should save the document to disk first (XmlDocument.Save) and open with
a text editor, so that you learn the structure of the document.

Then you can use XPath to select those parts that interest you.

The XML document's root element is DocumentElement itself and not it's
FirstChild.
--
Regards,
Dennis JD Myrén
Oslo Kodebureau
"A Golez" <al**********@gmail.com> wrote in message
news:39*************************@posting.google.co m...
Hello all,
I'm a complete newbie looking for a little advice. I am writing a Soap
Client to request weather data from the NOAA website.
(http://www.nws.noaa.gov/forecasts/xml/) and the response to the sent
request is returned in the form of a string. I know I have to use
something like XmlDocument/XmlNode to extract the text from the Xml
tags, but I'm having problems in doing in. Here's what I'm doing:
__________________________________________________ _____________________

private ndfdXML weatherXML = null;
private XmlDocument doc;
private XmlNode rootNode;
private XmlNodeList wList;
private DateTime startDataTime;
.....

weatherXML = new ndfdXML(); //create proxy
startDateTime = new DateTime(2005, 2, 4, 9, 15, 0);

String wStr;
XmlNode nextNode;

wStr = weatherXML.NDFDgenByDay(39, -77, startDateTime, "1",

gov.weather.formatType.Item24hourly);

//Append the XML document to the main window
doc = new XmlDocument();
doc.LoadXml(wStr);

rootNode = doc.DocumentElement.FirstChild;

int j;

if (rootNode.HasChildNodes)
{

for (j=0; j<rootNode.ChildNodes.Count; j++)
{
nextNode = rootNode.NextSibling;
WeatherBox.AppendText(nextNode.InnerText + "\n");
}
}

Nov 16 '05 #2

P: n/a
Golez,
I have done that exact thing in the past. It's a little application in your
taskbar that displays the current temp.
Zip file with the codes is at http://dowhileloop.com/downloads/weather.zip
Code is documented pretty well and you shouldn't have trouble following it.
Hope you find it helpful.
--
in**@dowhileloop.com
http://dowhileloop.com
http://publicjoe.dowhileloop.com -- .NET Tutorials
"A Golez" <al**********@gmail.com> wrote in message
news:39*************************@posting.google.co m...
Hello all,
I'm a complete newbie looking for a little advice. I am writing a Soap
Client to request weather data from the NOAA website.
(http://www.nws.noaa.gov/forecasts/xml/) and the response to the sent
request is returned in the form of a string. I know I have to use
something like XmlDocument/XmlNode to extract the text from the Xml
tags, but I'm having problems in doing in. Here's what I'm doing:
__________________________________________________ _____________________

private ndfdXML weatherXML = null;
private XmlDocument doc;
private XmlNode rootNode;
private XmlNodeList wList;
private DateTime startDataTime;
.....

weatherXML = new ndfdXML(); //create proxy
startDateTime = new DateTime(2005, 2, 4, 9, 15, 0);

String wStr;
XmlNode nextNode;

wStr = weatherXML.NDFDgenByDay(39, -77, startDateTime, "1",

gov.weather.formatType.Item24hourly);

//Append the XML document to the main window
doc = new XmlDocument();
doc.LoadXml(wStr);

rootNode = doc.DocumentElement.FirstChild;

int j;

if (rootNode.HasChildNodes)
{

for (j=0; j<rootNode.ChildNodes.Count; j++)
{
nextNode = rootNode.NextSibling;
WeatherBox.AppendText(nextNode.InnerText + "\n");
}
}

Nov 16 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.