如何使用 NSXMLParser 访问完全相同的元素
我有一个需要解析的 XML 文件。如下(为了清晰起见,将其删除):
<rss version="2.0" xmlns:yweather="http://xml.weather.yahoo.com/ns/rss/1.0" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#">
<channel>
<item>
<title>Yahoo! Weather - Somecity</title>
<yweather:astronomy sunrise="6:52 am" sunset="5:36 pm"/>
<yweather:forecast day="Wed" date="16 Feb 2011" low="39" high="59" text="Mostly Sunny" code="34"/>
<yweather:forecast day="Thu" date="17 Feb 2011" low="29" high="50" text="Mostly Sunny" code="34"/>
</item>
</channel>
</rss>
问题是,正如您所看到的,有两个 yweather:forecast 元素,并且两者都没有任何可用于区分二。有什么想法吗?
I have an XML file I'm needing to parse. Here it is (stripped for clarity):
<rss version="2.0" xmlns:yweather="http://xml.weather.yahoo.com/ns/rss/1.0" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#">
<channel>
<item>
<title>Yahoo! Weather - Somecity</title>
<yweather:astronomy sunrise="6:52 am" sunset="5:36 pm"/>
<yweather:forecast day="Wed" date="16 Feb 2011" low="39" high="59" text="Mostly Sunny" code="34"/>
<yweather:forecast day="Thu" date="17 Feb 2011" low="29" high="50" text="Mostly Sunny" code="34"/>
</item>
</channel>
</rss>
The problem is, as you can see, there are two yweather:forecast
elements, and both don't have any static text that can be used to differentiate between the two. Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
啊,结果很容易。这就是我所做的:
小菜一碟,对吧? :)
Ah, ended up being quite easy. Here's what I did:
Piece of cake, right? :)