[Solved] Filtering data in XMLListModel
-
Hello,
I want to know how can we filter data in XMLListModel.
Let's say I've following XML file:
@<root>
<file>image1.jpeg<file>
<file>tune.mp3<file>
<file>image2.jpeg<file>
</root>@and I want to fetch all file names which have ".jpeg" extension. XPath defines contains() function to compare strings; is it supported by QML ?
-
I think so yes, but why don't you just try and see?
-
Hi,
Thanks for your reply. I was making a mistake while writing XPath predicate. Following model works for me now.
@XmlListModel {
source: "mysource.xml"
query: "/root/file[contains(.,'jpeg')]"XmlRole { name: "name"; query: "string()" }
}@
-
Glad that it works for you, and thanks for reporting back!