我正在嘗試使用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");
}
WebService的回發一個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>
但是,當我嘗試在XmlDocument的我得到XmlDoc.Load的ArguementException(路徑中具有非法字符)來加載結果(SoapResult );
我在做什麼錯?
[XmlDocument.LoadXml(SoapResult)](http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.loadxml.aspx) – Filburt
@Filburt感謝您指出了這一點! – V4Vendetta
啊謝謝Filburt! –