QML从XML文件中取路径的问题,帮下忙
XmlListModel {
id: xmlUrl
source: "data.xml"
query: "/xml_api_reply/weather/current_conditions"
XmlRole { name: "icon"; query: "icon/@data/string()" }
}
Image{
source: ??????
}
上面的那个icon就是XML文件中存储路径的位置,怎么样取出来放在Image的source里,大家帮帮忙,先谢谢了~~
[最优解释]
Image{
id: image
}
XmlListModel {
id: xmlUrl
source: "data.xml"
query: "/xml_api_reply/weather/current_conditions"
XmlRole { name: "icon"; query: "icon/@data/string()"
onStatusChanged: {
if (status == XmlListModel.Ready && count > 0) {
image.source = model.get(0).number
}
}
}
XmlListModel {
id: model
source: "netxml.xml"
query: "/rss/mediaDisplay"
XmlRole { name: "icon"; query: "backgroundDisplay/image/string()" }
onStatusChanged: {
if (status == XmlListModel.Ready && count > 0) {
image.source = model.get(0).icon
console.log(model.get(0).icon);
}
}
}
Image {
id: image
}
弄了好几天了,还是没有找到问题,能帮帮我吗?
[其他解释]
http://download.csdn.net/download/fq15973135977/4212246
我以前发这个帖就是为了做上面那个天气预报的,现在好久没接触了,你下载下来看看,对比一下吧~