I try to parse a XML-file with the following structure:
For XML things, it was suggested to use QXmlStreamReader and QXmlStreamWriter from QtCore module, just because the QDom and QSax things have been not actively maintained for a while.
http://doc.qt.digia.com/4.7/qxmlstreamreader.html
http://doc.qt.digia.com/4.7/qxmlstreamwriter.html
I will not copy&paste the example code from qt docs to here. Hope you could understand them well. And you also could check examples/xml directory in qt 4.x.
Untested, but this is a way I already used Qt to scan in a very simply XML file. Maybe this can give you a hint how to use it here:
QDomElement docElem;
QDomDocument xmldoc;
xmldoc.setContent(YOUR_XML_DATA);
docElem=xmldoc.documentElement();
if (docElem.nodeName().compare("T")==0)
{
QDomNode node=docElem.firstChild();
while (!node.isNull())
{
quint32 number = node.toElement().attribute("t").toUInt(); //or whatever you want to find here..
//do something
node = node.nextSibling();
}
}
you could use QXmlQuery. It act like XQuery (i guess the syntax is the same). And you could parse your xml file with the big advantage of XQuery's flexibility. You can start with a code like this:
QByteArray myDocument;
QBuffer buffer(&myDocument); // This is a QIODevice.
buffer.open(QIODevice::ReadOnly);
QXmlQuery query;
query.bindVariable("myDocument", &buffer);
query.setQuery("doc($myDocument)");
setQuery method allow you to define your search pattern. It can be based on element id, attribute, and so on...as with XQuery. This is QXmlQuery doc page: link