【发布时间】:2016-12-22 16:12:23
【问题描述】:
我使用天气 API 以 XML 格式返回温度值并将它们写入文本文件。我的下一步是从 XML 文件中读取值以在我的程序中使用。这是值的格式;
<temperature value="21.37" min="18.89" max="22.78" unit="metric">
</temperature>
<humidity value="68" unit="%">
</humidity>
<pressure value="1019" unit="hPa">
</pressure>
我想访问温度值,但我不确定如何通过从文本文件中读取来做到这一点,特别是考虑到文本文件比我需要的要长得多。访问我想要的值的最有效方法是什么?
编辑:
<current>
<city id="" name="">
<coord lon="-0.45" lat="52.19">
</coord>
<country>GB</country>
<sun rise="2016-08-16T04:48:13" set="2016-08-16T19:22:26">
</sun>
</city>
<temperature value="22.06" min="19.44" max="23.89" unit="metric">
</temperature>
<humidity value="67" unit="%">
</humidity>
<pressure value="1019" unit="hPa">
</pressure>
<wind>
<speed value="2.57" name="Light breeze">
</speed>
<gusts value="6.17">
</gusts>
<direction value="73" code="ENE" name="East-northeast">
</direction>
</wind>
<clouds value="24" name="few clouds">
</clouds>
<visibility>
</visibility>
<precipitation mode="no">
</precipitation>
<weather number="801" value="few clouds" icon="02d">
</weather>
<lastupdate value="2016-08-16T10:44:02">
</lastupdate>
</current>
【问题讨论】:
标签: c# xml file weather-api