Hi,
Is it possible to get both an element attribut and the elements childnodes? What I want to accomplish is an scrollable list of elements having the element attribute as title and below that all children content.
If for example the xml was something like this:
In other words, the xml could contain many authors and every author could have many books.Code:<?xml version="1.0"?> <authors> <author name"Mickey Mouse"> <book> <pubdate>1994</pubdate> <pageCount>45</pageCount> </book> </author> <author name"Donald Duck"> <book> <pubdate>1957</pubdate> <pageCount>87</pageCount> </book> <book> <pubdate>1963</pubdate> <pageCount>12</pageCount> </book> </author> </authors>
I'd like to get this into an XMLListModel.
I tried to query all authors, and i get a list of them, but how can I get another list for evey author to display variable count of books?
It seems it is not possible to put an XMLListModel into another.
I also tryd to query all books instead and then to get the author by using xpath for parent node in the xmlrole. It seemed to me that XMLListModel does not support xpath for getting parents, or then i just didnt write proper xpath.
Edit:
The xml I wrote was just an example and has some errors. I completed my example and the xml seems to work fine for the attribute, but the problem to get all books into the XMLListModel still remains:
The qml I've used in the example looks like this:Code:<?xml version="1.0"?> <authors> <author name="Mickey Mouse"> <book> <pubdate>1994</pubdate> <pageCount>45</pageCount> </book> <book> <pubdate>1991</pubdate> <pageCount>32</pageCount> </book> </author> <author name="Donald Duck"> <book> <pubdate>1957</pubdate> <pageCount>87</pageCount> </book> <book> <pubdate>1963</pubdate> <pageCount>12</pageCount> </book> </author> </authors>
I get the the author name properly, but is it possible to display the authors books below the authors somehow?Code:import QtQuick 1.0 Rectangle { id: window width: 640 height: 360 XmlListModel { id: authors //xml: "/authors.xml" Couldn't get local file to work at all.. source: "http://myserver.com/authors.xml" query: "/authors/author" XmlRole { name: "author"; query: "@name/string()" } } ListView { id: authorsList anchors.fill: parent model: authors delegate: Text { text: "Author name: " + author; } } }
Best Regards,
Sebastian



