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="xxxx...@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="73432...@n00"
username="mrksaari" dateadded="1282240674" />
<event type="comment" user="73432...@n00"
username="mrksaari" dateadded="1282240680" commentid="72157624636490171">Hyvä
tuli!</event>
<event type="comment" user="37079...@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="24596...@n04"
username="kayven.com<http://kayven.com/>" dateadded="1282287713" />
<event type="comment" user="33203...@n06"
username="Antoine et Alice" dateadded="1282300226"
commentid="72157624765816330">waaaa magnifique ! bravo !</event>
<event type="fave" user="52347...@n03"
username="sssourabh" dateadded="1282314559" />
<event type="fave" user="38098...@n00" username="Jamie
McDonald Photography" dateadded="1282324021" />
<event type="fave" user="28454...@n04"
username="R3MarkAble" dateadded="1282336445" />
<event type="fave" user="42864...@n02"
username="M.AL-ZAID «WAH»" dateadded="1282484411" />
<event type="comment" user="42864...@n02"
username="M.AL-ZAID «WAH»" dateadded="1282484467"
commentid="72157624655970811">What a great pic!</event>
<event type="fave" user="9174...@n07" username="Jessyca
Silva" dateadded="1282496183" />
<event type="fave" user="38867...@n05" username="Jaime
Schultz Photography" dateadded="1282703274" />
<event type="fave" user="44124439...@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="28454...@n04" username="R3MarkAble"
dateadded="1282336445" />
<event type="comment" user="73432...@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
_______________________________________________
Qt-qml mailing list
[email protected]
http://lists.trolltech.com/mailman/listinfo/qt-qml