2011-06-20 30 views
2

オランダの現在の天気を取得するWebServiceを使用しようとしています。 XML - ヘッダーに不正な文字が含まれています

 public void GetWeather() 
    { 
     net.webservice.GlobalWeather.GlobalWeather GlobalWeatherService = new net.webservice.GlobalWeather.GlobalWeather(); 
     string SoapResult = GlobalWeatherService.GetWeather(Location, "Netherlands"); 

     XmlDocument XmlDoc = new XmlDocument(); 
     XmlDoc.Load(SoapResult); 
     XmlNodeList XmlForecast = XmlDoc.GetElementsByTagName("CurrentWeather"); 
    } 

バックWebサービスポスト文字列としてXMLファイル

<?xml version="1.0" encoding="utf-16"?> 
<CurrentWeather> 
<Location>Amsterdam Airport Schiphol, Netherlands (EHAM) 52-18N 004-46E -2M</Location> 
<Time>Jun 20, 2011 - 06:25 AM EDT/2011.06.20 1025 UTC</Time> 
<Wind> from the SW (220 degrees) at 9 MPH (8 KT):0</Wind> 
<Visibility> greater than 7 mile(s):0</Visibility> 
<SkyConditions> partly cloudy</SkyConditions> 
<Temperature> 62 F (17 C)</Temperature> 
<DewPoint> 51 F (11 C)</DewPoint> 
<RelativeHumidity> 67%</RelativeHumidity> 
<Pressure> 29.88 in. Hg (1012 hPa)</Pressure> 
<Status>Success</Status> 
</CurrentWeather> 

しかし、私は、私はXmlDoc.Load上ArguementException(パスに無効な文字)を取得XmlDocumentオブジェクトに結果をロードしようとすると、(SoapResult );

私は間違っていますか?

答えて

3

XmlDocument.Loadを(使用してわかるように、このGlobalWeatherService.GetWeather(Location, "Netherlands")

をロードする必要がある実際の文字列

入力のparamとしてファイルパスを取り、ない、XMLドキュメントをロードしますロードするXML文書を含むファイルの、指定されたURLから取得します。 URLは、ローカルファイルまたはHTTP URL(Webアドレス)のいずれかです。

例外ArgumentExceptionファイル名が長さゼロの文字列、空白のみ、または1つ以上の無効な文字を含む場合。

代わりにLoadXml()を使用してください。

1

XmlDoc.Load)は、多分あなたはFilburtがXmlDoc.LoadXml

+2

[XmlDocument.LoadXml(SoapResult)](http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.loadxml.aspx) – Filburt

+0

@Filburtはそれを指摘してくれてありがとう! – V4Vendetta

+0

ああ、ありがとうFilburt! –

関連する問題