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();
???
}
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();
???
}
To copy to clipboard, switch view to plain text mode
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") ;
QString colorValue = item->Attribute("color") ;
To copy to clipboard, switch view to plain text mode
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);
QXmlResultItems xppElements;
QXmlQuery query2;
query2.setQuery("subElements\element");
query2.evaluate(xmlItem->Node(), xppElements);
To copy to clipboard, switch view to plain text mode
Thanks for your help
Bookmarks