[solved] XmlListModel parse local xml file
-
@ XmlListModel {
id: xmlModel
source:"local.xml"query: "/feed/entry" namespaceDeclarations: "declare default element namespace 'http://www.w3.org/2005/Atom';" XmlRole { name: "title"; query: "content/string()"} } Component { id: xmlModelDelegate Text { width: 350 text: title wrapMode:Text.Wrap } } ListView { id:parseHtmlListview width: parent.width height: parent.height - 40 clip: true model: xmlModel delegate: xmlModelDelegate }
//local.xml such as follow
<feed>
<entry>
<content type="html">
<div id="Intro"><p>Hello World.</p> ></div>
</content>
</entry>
</feed>
@hi, when i use XmlListModel parse loacl xml file, i can't get data, please help me, thanks~~~
-
I guess you have correct namespace in xml (code-tags seems to remove the namespace...)
If you want hello world text:
@XmlListModel {
...
XmlRole { name: "title"; query: "content/div/p/string()"}
}@ -
Hi Diph,
Thanks for your reply.
I am sorry i did't describe the problem exactly.
I can phase the xml file when it is in server.
But after i downloaded it from server to my computer, I can't phase it from local.
As the same file content, I don't know why it doesn't work.
Do u have any idea about this?[quote author="Diph" date="1313584756"]I guess you have correct namespace in xml (code-tags seems to remove the namespace...)
If you want hello world text:
@XmlListModel {
...
XmlRole { name: "title"; query: "content/div/p/string()"}
}@[/quote] -
Maybe it is located in another place? Not where qml looks for it?
-
Maybe you can set your own QNetworkAccessManager which uses cache? http://doc.qt.nokia.com/latest/qdeclarativenetwork.html#configuring-the-network-access-manager
-
the problem have been resolved.
encoding caused the problem.
the file must be unicode format.
thanks for all your reply.