Given the following XML source with 2 nested levels:
<papers>
<paper id="1">
<authors>
<author name="John Doe" />
<author name="Jane Doe" />
</authors>
</paper>
<paper id="2">
<authors>
<author name="John Appleseed" />
</authors>
</paper>
</papers>
when I define an XmlRole in my XmlListModel like:
XmlListModel {
id: myPapers
source: "http://example.com/papers.xml"
query: "/papers/paper"
XmlRole { name: "author"; query: "authors/author/@name/string()" }
}
it will contain all 3 authors, not only the 2 "Doe" authors from the first paper. I can add an index (authors/author[1]) in the role but I don't now how many papers and authors there will be. Defining author1, author2, ..., author99 doesn't feel like the right approach.
How do I tell the XmlListModel I only want the authors of one paper in a ListView?
ListView {
model: myPapers
delegate: Text { text: author }
}
Now shows:
John Doe
Jane Doe
John Appleseed <-- don't want this one
Thanks!
UPDATE 1 The source file is a URL and I prefer not to fetch the same file multiple times to get the data (it's for a mobile app).
UPDATE 2 upsideout on #qt-quick told me it's better to use a ListView instead of a Repeater. Don't understand why yet. Modified the question accordingly.