PDA

View Full Version : Xpath & QT



pl01
15th November 2010, 12:48
Hi,

I'm trying to use XPath with the QT libraries. For now I do the following :



QXmlQuery query;
query.bindVariable("inputURI", QVariant(filename));

query.setQuery("doc($inputURI)//aurora/scene/camera");

QXmlResultItems xppCamera;
query.evaluateTo(&xppCamera);
for (QXmlItem item = xppCamera.next(); !item.isNull(); item = xppCamera.next())
{
const QAbstractXmlNodeModel* model = item.toNodeModelIndex().model();
???
}


So, I have 3 problems :
1 - It seems that I never go inside the for loop !
2 - How can I get an attribute. Something like this that will give me the value


QString colorValue = item->Attribute("color") ;

3 - How can I get a "sub node" and recreate a new xquery on it. Something like this


QXmlResultItems xppElements;
QXmlQuery query2;
query2.setQuery("subElements\element");
query2.evaluate(xmlItem->Node(), xppElements);


Thanks for your help