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
Forum Updated to NodeBB v4.3 + New Features

Custom query in XmlListModel

Scheduled Pinned Locked Moved Solved QML and Qt Quick
xmllistcustom query
3 Posts 2 Posters 1.0k 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.
  • C Offline
    C Offline
    CharlieG
    wrote on 12 Jul 2016, 13:47 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
    • D Offline
      D Offline
      dheerendra
      Qt Champions 2022
      wrote on 12 Jul 2016, 16:23 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
      http://www.pthinks.com

      1 Reply Last reply
      3
      • C Offline
        C Offline
        CharlieG
        wrote on 14 Jul 2016, 14:35 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

        3/3

        14 Jul 2016, 14:35

        • Login

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