我在使用javascript解析雅虎的天气api时遇到问题。我有一切工作,但我无法弄清楚如何获得多天的数据。我可以得到第一个,但不知道如何获得其他属性。Yahoo天气预报xml
这里是XML部分:
<yweather:forecast day="Sun" date="24 Feb 2013" low="19" high="31" text="Few Snow Showers" code="14"/>
<yweather:forecast day="Mon" date="25 Feb 2013" low="24" high="35" text="Partly Cloudy" code="30"/>
<yweather:forecast day="Tue" date="26 Feb 2013" low="33" high="34" text="Rain/Snow Showers" code="5"/>
<yweather:forecast day="Wed" date="27 Feb 2013" low="31" high="35" text="Snow Showers" code="14"/>
<yweather:forecast day="Thu" date="28 Feb 2013" low="25" high="33" text="Few Snow Showers" code="14"/>
而这种代码会得到我的第一个预测
forecastTag = findChild(findChild(effectiveRoot, "item"), "yweather:forecast");
day1 = forecastTag.getAttribute("low");
所以我怎么为其他日子的数据?我已经尝试过处理yweather:预测为数组[0],[1]等......但它不起作用。我一直在阅读很多关于解析的内容,但无法弄清楚。我是XML新手。
感谢 小号