[Qt-qml] Error querying root item of XmlListModel

bea.lam at nokia.com bea.lam at nokia.com
Tue Oct 18 10:32:26 CEST 2011


On 18/10/2011, at 1:25 AM, ext Girish Ramakrishnan wrote:

> Hi,
> Someone on irc was having trouble with the XmlListModel and I was
> trying to help him/her out. I don't know xquery/xpath well enough to
> know if this is a problem with my example or xmlpatterns. So, I
> reduced the problem to this: http://pastebin.com/Gdmc2Gzq works but
> http://pastebin.com/pMnvFYQQ doesn't. Basically, if I query anything
> directly under the root element, XmlListModel just reports an error.
> Querying any level one below the root element, it works fine.


To confirm, this is because this XML data in http://pastebin.com/pMnvFYQQ has multiple "Category" objects:

<?xml version="1.0" encoding="utf-8"?>
<MediaList>
    <Category name="name1">Something here</Category>
    <Category name="name2">Something there</Category>
</MediaList> 


Since there are multiple query items, it doesn't know which one to fetch. The query should be "Category[1]/@name/string()" to fetch the exact index, or it should use a model that puts the query at "MediaList/Category" instead. 

Related to this is https://bugreports.qt.nokia.com/browse/QTBUG-12953 which suggests being able to create an XmlObject to cater for list objects.


regards,

Bea



More information about the Qt-qml mailing list