2013-01-03 101 views
0

我已經完成了xml解析,然後使用了Ray Wenderlich的一些指南,但這些指南通常用於涉及多個項目的情況。我正在努力讓應用程序在給定的時間顯示天氣狀況,並且該提要的XML僅具有檢查時間的條件。這是有問題的飼料:iOS簡單的XML天氣解析

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> 
     <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> 

<title>Yahoo! Weather - Montgomery, AL</title> 
<link>http://us.rd.yahoo.com/dailynews/rss/weather/Montgomery__AL/*http://weather.yahoo.com/forecast/USAL0375_f.html</link> 
<description>Yahoo! Weather for Montgomery, AL</description> 
<language>en-us</language> 
<lastBuildDate>Thu, 03 Jan 2013 11:55 am CST</lastBuildDate> 
<ttl>60</ttl> 
<yweather:location city="Montgomery" region="AL" country="United States"/> 
<yweather:units temperature="F" distance="mi" pressure="in" speed="mph"/> 
<yweather:wind chill="43" direction="0" speed="5" /> 
<yweather:atmosphere humidity="66" visibility="10" pressure="30.26" rising="2" /> 
<yweather:astronomy sunrise="6:46 am" sunset="4:52 pm"/> 
<image> 
<title>Yahoo! Weather</title> 
<width>142</width> 
<height>18</height> 
<link>http://weather.yahoo.com</link> 
<url>http://l.yimg.com/a/i/brand/purplelogo//uh/us/news-wea.gif</url> 
</image> 
<item> 
<title>Conditions for Montgomery, AL at 11:55 am CST</title> 
<geo:lat>32.38</geo:lat> 
<geo:long>-86.3</geo:long> 
<link>http://us.rd.yahoo.com/dailynews/rss/weather/Montgomery__AL/*http://weather.yahoo.com/forecast/USAL0375_f.html</link> 
<pubDate>Thu, 03 Jan 2013 11:55 am CST</pubDate> 
<yweather:condition text="Mostly Cloudy" code="28" temp="46" date="Thu, 03 Jan 2013 11:55 am CST" /> 
<description><![CDATA[ 
<img src="http://l.yimg.com/a/i/us/we/52/28.gif"/><br /> 
<b>Current Conditions:</b><br /> 
Mostly Cloudy, 46 F<BR /> 
<BR /><b>Forecast:</b><BR /> 
Thu - Partly Cloudy. High: 50 Low: 31<br /> 
Fri - Sunny. High: 57 Low: 35<br /> 
<br /> 
<a href="http://us.rd.yahoo.com/dailynews/rss/weather/Montgomery__AL/*http://weather.yahoo.com/forecast/USAL0375_f.html">Full Forecast at Yahoo! Weather</a><BR/><BR/> 
(provided by <a href="http://www.weather.com" >The Weather Channel</a>)<br/> 
]]></description> 
<yweather:forecast day="Thu" date="3 Jan 2013" low="31" high="50" text="Partly Cloudy" code="30" /> 
<yweather:forecast day="Fri" date="4 Jan 2013" low="35" high="57" text="Sunny" code="32" /> 
<guid isPermaLink="false">USAL0375_2013_01_04_7_00_CST</guid> 
</item> 
</channel> 
</rss> 

基本上,所有我需要的應用程序是該項目的標籤下包含yweather內的當前溫度和條件:條件標籤。使用GDataXML,獲取這些信息並設置NSString等於它的最簡單方法是什麼?

現在,我正在使用Ray的教程中的一些複雜的東西與asihttprequest和塊進行排序並將其全部放入NSMutableArray,但我相當肯定它現在不需要那麼複雜。

回答