Unsolved Parsing local XML file to ListModel via XmlListModel
-
Hello,
I have a problem with the XmlListModel object. I tried to read a dummy.xml input file, which is strucutred something like this:Dummy.xml:
<?xml version="1.0" encoding="utf-8"?>
<dummyroot>
<item>
<title>stuff 1</title>
<date>Sat, 07 Sep 2010 10:00:01 GMT</date>
</item>
<item>
<title>stuff 2</title>
<date>Sat, 07 Sep 2010 15:35:01 GMT</date>
</item>
</dummyroot>My QML code looks something like this:
main.qml
XmlListModel { id: xmlModel source: "file://C:/...../Dummy.xml" query: "/dummyroot/item" XmlRole { name: "title"; query: "title/string()"} XmlRole { name: "date"; query: "date/string()" } } Component{ id:xmlDelegate Row{ Text{text:title;color:"white"} Text{text:date;color:"white"} } }
with an additional ListView added to show the data. Sadly it wont show any data, nor print model inputs via print(xmlModel.get(0).title)...
I furthermore tested the loading state functionality via a function which looks like this:
function do_xmldata_work()
{
console.log("do_xmldata_work begin>: ")
while(xmlModel.status != XmlListModel.Ready)
console.log("loading xml file: " + xmlModel.status + " error Message" + xmlModel.errorString())
console.log("loading xml file: " + xmlModel.status + " || finished")
}The status is 1 or finished, but the ListView stays empty.
print(xmlModel.get(0).title) returns TypeError: Cannot read property 'title' of undefinedAny help would be much appreciated!
Thanks in advance!Stefan