Qt 6.11 is out! See what's new in the release
blog
[Solved] Filtering data in XMLListModel
QML and Qt Quick
4
Posts
2
Posters
5.1k
Views
1
Watching
-
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 ?
-
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()" }}@