Jump to content
Xtreme .Net Talk

Recommended Posts

Posted (edited)

I'm still learning to parse .XML in .NET and I'm having a problem where I'm receiving the following error and I can't figure it out, so any help would be greatly appreciated.

 

"Illegal characters in path"

 

The XML being returned is as follows:

[highlight=xml]

<?xml version="1.0" encoding="utf-8" ?>

<string xmlns="http://www.webserviceX.NET">

<?xml version="1.0" encoding="utf-16"?>

<CurrentWeather>

<Location>Newark, Newark Heath Airport, OH, United States (KVTA) 40-01-22N 082-27-45W 268M</Location>

<Time>Jun 05, 2007 - 08:54 PM EDT / 2007.06.06 0054 UTC</Time>

<Wind> from the N (350 degrees) at 3 MPH (3 KT):0</Wind>

<Visibility> 10 mile(s):0</Visibility>

<SkyConditions> clear</SkyConditions>

<Temperature> 62.1 F (16.7 C)</Temperature>

<DewPoint> 53.1 F (11.7 C)</DewPoint>

<RelativeHumidity> 72%</RelativeHumidity>

<Pressure> 29.77 in. Hg (1008 hPa)</Pressure>

<Status>Success</Status>

</CurrentWeather>

</string>

[/highlight]

d

dHere is how I am retrieving the XML.

 

string result;
globalWeatherWS.GlobalWeather gw = new globalWeatherWS.GlobalWeather();
result = gw.GetWeather("newark", "united states");
           
XPathDocument doc = new XPathDocument(result);
           
XPathNavigator nav = doc.CreateNavigator();

XPathExpression expr;
expr = nav.Compile("CurrentWeather");

XPathNodeIterator iterator = nav.Select(expr);

while (iterator.MoveNext())
{
   XPathNavigator nav2 = iterator.Current.Clone();
   textBox1.Text = nav2.Value;
}

Edited by PlausiblyDamp
Posted
Thanks for the reply. I noticed that to; however, this is what is returned by the web service. I was able to solve the problem, though by taking a different approach to parsing the returned XML data.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...