Created
March 27, 2015 09:02
-
-
Save cimm/7c88dfccfc15840afa6a to your computer and use it in GitHub Desktop.
Nested elements in a QML XmlListModel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import QtQuick 2.0 | |
import QtQuick.XmlListModel 2.0 | |
Rectangle { | |
width: 300 | |
height: 400 | |
XmlListModel { | |
id: xmlModel | |
source: "http://example.com/papers.xml" | |
query: "/papers/paper/authors/author" | |
XmlRole { name: "author"; query: "@name/string()" } | |
} | |
ListView { | |
anchors.fill: root | |
spacing: 20 | |
model: xmlModel.count | |
delegate: AuthorDelegate { | |
parentIndex: index | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<papers> | |
<paper id="1"> | |
<authors> | |
<author name="Author 1.1" /> | |
<author name="Author 1.2" /> | |
</authors> | |
</paper> | |
<paper id="2"> | |
<authors> | |
<author name="Author 2.1" /> | |
</authors> | |
</paper> | |
<paper id="3"> | |
<authors> | |
<author name="Author 3.1" /> | |
<author name="Author 3.2" /> | |
</authors> | |
</paper> | |
</papers> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment