XmlListModel - XmlRole ( Navigating to parent item)



  • Hello,

    I have an xml file like this :

    @
    <root>
    <a>
    <b>Text of b</b>
    <c prop="1"/>
    </a>
    <a>
    <b>Another text of b</b>
    <c prop="2--"/>
    </a>
    </root>
    @

    and have created an XmlListModel like this :

    @
    XmlListModel{
    source : "name.xml"
    query : "/a/c[prop = 1]"
    XmlRole{ name: "name" query:"../b/string()" }
    }
    @

    Although the query is executed successfully, I cannot get the values of a parent item.
    Any ideas?

    [EDIT: code formatting, Volker]



  • Ok this works for me now :

    @
    XmlListModel{
    source : "name.xml"
    query : "/a[c[prop = 1]]"
    XmlRole{ name: "name"; query:"b/string()" }
    }
    @



  • Cool, thanks! I was trying to solve the same problem myself.

    Hartti


Log in to reply
 

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