XmlRole - how to get values from query AND from parent element
-
hi,
I have an XML like this:
@<services>
<service id="1">
<option id="1" value="1"/>
<option id="2" value="2"/>
</service>
<service id="2">
<option id="1" value="1"/>
<option id="2" value="2"/>
</service>
</services>@I need to get list with options values AND with service IDs, like (service, option id, value):
1, 1, 1
1, 2, 2
2, 1, 1
2, 2, 2I was trying to set query to "/services/service/option". this gives all options, but i can't get service ID from parent element.
XmlRole { name: "serviceId"; query: "../@id/string()" } -- gives empty result. also tried several other XPath tricks, still nothing.unfortunately, i can't change XML, so, it is needed to solve this issue with other possibilities (preferably with standard QML)
thanks in advance
-
yep, this would work if i need only one service. but i need them all..
currently i made workaround (not sure if they are correct from rules point of view, but anyway they work for me)
- i get only "/services/service" and pass model to ListView. in ListView delegate i have another model with
@
property string serviceId
query: "/services/service[@id=" + serviceId + "]/options"
@
this is like "loop-in-loop"
- i get only "/services/service" and pass model to ListView. in ListView delegate i have another model with