Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Custom query in XmlListModel
Qt 6.11 is out! See what's new in the release blog

Custom query in XmlListModel

Scheduled Pinned Locked Moved Solved QML and Qt Quick
xmllistcustom query
3 Posts 2 Posters 1.5k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • CharlieGC Offline
    CharlieGC Offline
    CharlieG
    wrote on last edited by
    #1

    HI,

    Is it possible to customize a query in XmlListModel to get only elements which contain (for example) an specific attribute ?

    For example, I have this XML file :

    <root>
        <element type='type1'>
            ...
            ...
            ...
        </element>
        <element type='type1'>
            ...
            ...
            ...
        </element>
        <element type='type2'>
            ...
            ...
            ...
        </element>
    </root>
    

    In my XmlListModel, I want only get elements where type = type1.

    Thank you in advance.

    1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Moderators Qt Champions 2024 Qt Champions 2022 Qt Champions 2017
      wrote on last edited by
      #2

      This is not possible. It is better you build custom model in C++ by parsing the XML.

      Dheerendra
      @Community Service
      Certified Qt Specialist
      https://www.pthinks.com

      1 Reply Last reply
      3
      • CharlieGC Offline
        CharlieGC Offline
        CharlieG
        wrote on last edited by
        #3

        Hi,

        Too bad... :( :( :( :( ... but I think that : everything is possible with Qt & QML !!!! And I am right :

        XmlListModel {
            id: xmlModel
            source: "data.xml"
            query: "/root/element[@type='type1']"
        

        This solution allow to get only the element with type = type1.... Yoouuuupiiiiii ;-)

        Cooollll

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved