XmlRole with Flickr API
-
Trying to use QML with Flickr API calls.
The thing is that, for example, flickr.photosets.getPhotos call returns a weird looking XML, which looks pretty differently from RSS feed. Here it is:
<rsp stat="ok">
<photoset id="72157625173285745" primary="5140502686" owner="23802687@N06" ownername="Alexander Savin" page="1" per_page="500" perpage="500" pages="1" total="38">
<photo id="5140502686" secret="0ee829b415" server="1190" farm="2" title="Vintage photography from the attic" isprimary="1"/>
<photo id="5140505054" secret="faaeb624bb" server="4005" farm="5" title="Vintage photography from the attic" isprimary="0"/>..and so on.
The thing I'm trying is to parse owner value from this XML (which is "23802687@N06" in this case). Is it possible to do with XmlListModel and XmlRole? Or how this should be done in a proper way? Some JavaScript maybe?
Thanks!
-
Yes, assuming your XmlListModel query is "/rsp/photoset" then an XmlRole query value of "@owner/string()" would fetch the owner value. The "@" indicates you are fetching an attribute value. See http://doc.qt.nokia.com/4.7-snapshot/qml-xmlrole.html for more info.
-
Thanks, that should do!
-
is there any way to filter data (XQuery), lets say i want all the images where id starts with "7" or where owner name is "abc"
-
No, not at the moment. Currently xquery statements can only be used for modifying individual data values, rather than the data model itself.