For example, if there is an XML document like this:
- \quotefile qml/xmlrole.qml
+ \quotefile qml/xmlrole.xml
Here are some valid XPath expressions for XmlRole queries on this document:
\snippet qml/xmlrole.qml 0
\dots 4
\snippet qml/xmlrole.qml 1
+ Accessing the model data for the above roles from a delegate:
+
+ \snippet qml/xmlrole.qml 2
+
See the \l{http://www.w3.org/TR/xpath20/}{W3C XPath 2.0 specification} for more information.
*/
//![1]
// XmlRole queries will be made on <book> elements
- query: "/catalogue/book"
+ query: "/catalog/book"
// query the book title
XmlRole { name: "title"; query: "title/string()" }
}
//![1]
+//![2]
ListView {
width: 300; height: 200
model: model
delegate: Column {
- Text { text: title + " (" + type + ")"; font.bold: true }
+ Text { text: title + " (" + type + ")"; font.bold: wanted }
Text { text: first_author }
Text { text: year }
}
+//![2]
}
}
--- /dev/null
+<?xml version="1.0" encoding="iso-8859-1" ?>
+<catalog>
+ <book type="Online" wanted="true">
+ <title>Qt 5 Cadaques</title>
+ <year>2014</year>
+ <author>Juergen Bocklage-Ryannel</author>
+ <author>Johan Thelin</author>
+ </book>
+ <book type="Hardcover">
+ <title>C++ GUI Programming with Qt 4</title>
+ <year>2006</year>
+ <author>Jasmin Blanchette</author>
+ <author>Mark Summerfield</author>
+ </book>
+ <book type="Paperback">
+ <title>Programming with Qt</title>
+ <year>2002</year>
+ <author>Matthias Kalle Dalheimer</author>
+ </book>
+ </catalog>