我正在使用>http://www.weather.gov/forecasts/xml/DWMLgen/wsdl/ndfdXML.wsdl webservice通過調用GmlTimeSeries webmethod獲取天氣情況。現在我只想從xml中讀取溫度,天氣圖標鏈接的詳細信息。 XML有巨大的數據。任何人都可以提供一個想法從XML獲取所需的數據?解析c#中的天氣預報數據(來自NDFD)#
的XML看起來幾乎象下面這樣:Full XML File is Here
我想從下面的XML數據獲取北部沿海地區:
<gml:featureMember>
<app:Forecast_Gml2Point>
<gml:position>
<gml:Point srsName="EPSG:4326">
<gml:coordinates>-87.8859170,41.7450495</gml:coordinates>
</gml:Point>
</gml:position>
<app:validTime>2011-06-07T12:00:00</app:validTime>
<app:temperature>77.0</app:temperature>
</app:Forecast_Gml2Point>
</gml:featureMember>
<gml:featureMember>
<app:Forecast_Gml2Point>
<gml:position>
<gml:Point srsName="EPSG:4326">
<gml:coordinates>-87.8859170,41.7450495</gml:coordinates>
</gml:Point>
</gml:position>
<app:validTime>2011-06-07T15:00:00</app:validTime>
<app:temperature>90.0</app:temperature>
</app:Forecast_Gml2Point>
</gml:featureMember>
和天氣短語從下面:
<gml:featureMember>
<app:Forecast_Gml2Point>
<gml:position>
<gml:Point srsName="EPSG:4326">
<gml:coordinates>-87.8859170,41.7450495</gml:coordinates>
</gml:Point>
</gml:position>
<app:validTime>2011-06-08T03:00:00</app:validTime>
<app:weatherPhrase>Mostly Clear</app:weatherPhrase>
</app:Forecast_Gml2Point>
</gml:featureMember>
<gml:featureMember>
<app:Forecast_Gml2Point>
<gml:position>
<gml:Point srsName="EPSG:4326">
<gml:coordinates>-87.8859170,41.7450495</gml:coordinates>
</gml:Point>
</gml:position>
<app:validTime>2011-06-08T06:00:00</app:validTime>
<app:weatherPhrase>Mostly Clear</app:weatherPhrase>
</app:Forecast_Gml2Point>
</gml:featureMember>
以上是一段xml文件。像這樣我有7天天氣細節的大數據。我需要從上面的XML讀取溫度和天氣狀況。
我試着用XDocument.Parse()方法解析xml。但無法閱讀'' –
2011-06-07 11:37:38