Quantcast
Channel: Jobs
Viewing all articles
Browse latest Browse all 18427

QtXmlPatterns using QXmlItem to focus in QXmlQuery cannot get results.

$
0
0
Hi all, I try to query a node say the following :”/TestRun/Config/Test/PA/Pulse” with the code bellow:     QFile* file = new QFile("/home/user/hardwaretest.xml");     qDebug() << file->open(QIODevice::ReadOnly);       QXmlQuery query;       query.setFocus(file);     query.setQuery("/TestRun/Config/Test/PA/Pulse");       QXmlResultItems* results = new QXmlResultItems();     query.evaluateTo(results);       QXmlItem item = results->next();       while(!item.isNull())     {         if(item.isNode())         {           QXmlQuery query2;             query2.setFocus(item);            query2.setQuery("./@pulseWidth/string()");             QXmlResultItems* results2 = new QXmlResultItems();           query2.evaluateTo(&results2);             QXmlItem item2 = results2->next();             while(!item2.isNull())           {             if(item2.isAtomicValue())                 qDebug() << item2.toAtomicValue().toString();             if(item2.isNode())                 qDebug() << "item2 is a node";             item2 = results2->next();           }           delete results2;         }       item = results->next();     }       file->close();     delete file;     delete results; Here is a part of my xml file : <?xml version="1.0" encoding="UTF-8"?> <TestRun>    <Config>       <Test name="Pulser">                <!-- amplitude % - pulseWidth % - riseTime V/ns - reverberation % -->                 </PA>       <UT>          <!-- amplitude % - pulseWidth % - riseTime V/ns - reverberation % -->                 </UT>       </Test> <TestRun> I do get the node   on the first query, but the second only return an empty node… I never were able to get results with QXmlQuery focused on an QXmlItem. Somebody knows what I do wrong here? Thank in advance.

Viewing all articles
Browse latest Browse all 18427

Trending Articles