[Qt-qml] How to use XmlRole with more complex XML
michael.brasser at nokia.com
michael.brasser at nokia.com
Mon Aug 30 02:25:27 CEST 2010
On 27/08/2010, at 5:54 PM, ext Marko Mattila wrote:
I've been trying to figure out how to get data out of XML when dealing with little bit more complex XML than is dealt in the Qt Quick examples or in XmlQuery documentation. Here is the xml:
<?xml version="1.0" encoding="utf-8" ?>
<rsp stat="ok">
<items page="1" pages="1" perpage="30" total="5">
<item type="photo" id="4907560415" owner="xxxxxxx at xxx" ownername="markoallan" secret="xxxxx" server="4143" farm="5" comments="4" notes="0" views="208" faves="9">
<title>The final version of Aarne Schmitt CD cover</title>
<activity>
<event type="fave" user="73432421 at N00" username="mrksaari" dateadded="1282240674" />
<event type="comment" user="73432421 at N00" username="mrksaari" dateadded="1282240680" commentid="72157624636490171">Hyvä tuli!</event>
<event type="comment" user="37079944 at N08" username="markoallan" dateadded="1282245723" commentid="72157624636988165">mrksaari: Kiitos! Olen itsekin ihan tyytyväinen varsinkin tuo oli vähän &quot;kokeellinen&quot; projekti maalien takia.</event>
<event type="fave" user="24596704 at N04" username="kayven.com<http://kayven.com/>" dateadded="1282287713" />
<event type="comment" user="33203590 at N06" username="Antoine et Alice" dateadded="1282300226" commentid="72157624765816330">waaaa magnifique ! bravo !</event>
<event type="fave" user="52347742 at N03" username="sssourabh" dateadded="1282314559" />
<event type="fave" user="38098504 at N00" username="Jamie McDonald Photography" dateadded="1282324021" />
<event type="fave" user="28454793 at N04" username="R3MarkAble" dateadded="1282336445" />
<event type="fave" user="42864672 at N02" username="M.AL-ZAID «WAH»" dateadded="1282484411" />
<event type="comment" user="42864672 at N02" username="M.AL-ZAID «WAH»" dateadded="1282484467" commentid="72157624655970811">What a great pic!</event>
<event type="fave" user="9174689 at N07" username="Jessyca Silva" dateadded="1282496183" />
<event type="fave" user="38867489 at N05" username="Jaime Schultz Photography" dateadded="1282703274" />
<event type="fave" user="44124439915 at N01" username="timsamoff" dateadded="1282755466" />
</activity>
</item>
</item>
</rsp>
So what kind of XPath query I should create in XmlListModel order to get these repeating nodes such as:
<event type="fave" user="28454793 at N04" username="R3MarkAble" dateadded="1282336445" />
<event type="comment" user="73432421 at N00" username="mrksaari" dateadded="1282240680" commentid="72157624636490171">Hyvä tuli!</event>
I'd like to be able to access all the information of these "events" from the QML delegate. In other words I need to to be able display all the data /per comment or fave event in my delegate.
Hi Marko,
The approach outlined by Bea in http://lists.trolltech.com/pipermail/qt-qml/2010-August/000856.html (an XmlListModel within the delegate operating on the sub-list) should work for this case, though it is admittedly not ideal.
Currently XmlListModel only really handles simple role types like string and number well. In the future we'd like to better handle embedded lists and objects -- see for example http://bugreports.qt.nokia.com/browse/QTBUG-12953.
Regards,
Michael
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt.nokia.com/pipermail/qt-qml/attachments/20100830/41edcbdf/attachment.html
More information about the Qt-qml
mailing list