Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Call for Presentations - Qt World Summit

    Solved Custom query in XmlListModel

    QML and Qt Quick
    xmllist custom query
    2
    3
    754
    Loading More Posts
    • 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.
    • CharlieG
      CharlieG last edited by

      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 Reply Quote 0
      • dheerendra
        dheerendra Qt Champions 2022 last edited by

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

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

        1 Reply Last reply Reply Quote 3
        • CharlieG
          CharlieG last edited by

          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 Reply Quote 0
          • First post
            Last post