日期:2014-05-17 浏览次数:20487 次
<?xml version="1.0"?><xml_api_reply version="1"><weather module_id="0" tab_id="0" mobile_row="0" mobile_zipped="1" row="0" section="0" ><forecast_information><city data="Beijing, Beijing"/><postal_code data="Beijing"/><latitude_e6 data=""/><longitude_e6 data=""/><forecast_date data="2012-04-21"/><current_date_time data="2012-04-21 19:00:00 +0000"/><unit_system data="SI"/></forecast_information><current_conditions><condition data="阴"/><temp_f data="57"/><temp_c data="14"/><humidity data="湿度: 82%"/><icon data="/ig/images/weather/cn_overcast.gif"/><wind_condition data="风向: 北、风速:1 米/秒"/></current_conditions><forecast_conditions><day_of_week data="周六"/><low data="7"/><high data="19"/><icon data="/ig/images/weather/mostly_sunny.gif"/><condition data="以晴为主"/></forecast_conditions><forecast_conditions><day_of_week data="周日"/><low data="12"/><high data="25"/><icon data="/ig/images/weather/mostly_sunny.gif"/><condition data="以晴为主"/></forecast_conditions><forecast_conditions><day_of_week data="周一"/><low data="16"/><high data="29"/><icon data="/ig/images/weather/sunny.gif"/><condition data="晴"/></forecast_conditions><forecast_conditions><day_of_week data="周二"/><low data="10"/><high data="20"/><icon data="/ig/images/weather/chance_of_rain.gif"/><condition data="可能有雨"/></forecast_conditions></weather></xml_api_reply>
XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(Server.MapPath("~/test.xml")); XmlNodeList nodes = xmlDoc.SelectNodes(@"//forecast_conditions"); foreach (XmlNode node in nodes) { Response.Write(node["low"].Attributes["data"].Value + "<br/>"); Response.Write(node["high"].Attributes["data"].Value + "<br/>"); Response.Write(node["condition"].Attributes["data"].Value + "<br/>"); Response.Write("<br/><br/>"); }