Custom query in XmlListModel



  • 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.



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



  • 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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.