当前位置: 代码迷 >> QT开发 >> QML怎么查询xml标签里面带冒号的属性呢
  详细解决方案

QML怎么查询xml标签里面带冒号的属性呢

热度:43   发布时间:2016-04-25 03:52:54.0
QML如何查询xml标签里面带冒号的属性呢?
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 - Chengde, CH</title>
<link>http://us.rd.yahoo.com/dailynews/rss/weather/Chengde__CH/*http://weather.yahoo.com/forecast/CHXX0302_c.html</link>
<description>Yahoo! Weather for Chengde, CH</description>
<language>en-us</language>
<lastBuildDate>Mon, 24 Sep 2012 1:59 pm CST</lastBuildDate>
<ttl>60</ttl>
<yweather:location city="Chengde" region=""   country="CH"/>
<yweather:units temperature="C" distance="km" pressure="mb" speed="km/h"/>
<yweather:wind chill="23"   direction="140"   speed="6.44" />
<yweather:atmosphere humidity="45"  visibility=""  pressure="1017.6"  rising="0" />
<yweather:astronomy sunrise="5:57 am"   sunset="6:00 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 Chengde, CH at 1:59 pm CST</title>
<geo:lat>40.97</geo:lat>
<geo:long>117.93</geo:long>
<link>http://us.rd.yahoo.com/dailynews/rss/weather/Chengde__CH/*http://weather.yahoo.com/forecast/CHXX0302_c.html</link>
<pubDate>Mon, 24 Sep 2012 1:59 pm CST</pubDate>
<yweather:condition  text="Mostly Cloudy"  code="28"  temp="23"  date="Mon, 24 Sep 2012 1:59 pm CST" />
<description><![CDATA[
<img src="http://l.yimg.com/a/i/us/we/52/28.gif"/><br />
<b>Current Conditions:</b><br />
Mostly Cloudy, 23 C<BR />
<BR /><b>Forecast:</b><BR />
Mon - Mostly Cloudy. High: 24 Low: 11<br />
Tue - Cloudy. High: 23 Low: 12<br />
<br />
<a href="http://us.rd.yahoo.com/dailynews/rss/weather/Chengde__CH/*http://weather.yahoo.com/forecast/CHXX0302_c.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="Mon" date="24 Sep 2012" low="11" high="24" text="Mostly Cloudy" code="27" />
<yweather:forecast day="Tue" date="25 Sep 2012" low="12" high="23" text="Cloudy" code="26" />
<guid isPermaLink="false">CHXX0302_2012_09_25_7_00_CST</guid>
</item>
</channel>
</rss>

QML解析部分如下:

    XmlListModel
         {
             id: model_weather
             source:"weather_chengde.xml"
  相关解决方案