Parse a xml file using c++ & Qt

后端 未结 3 1873
夕颜
夕颜 2021-02-09 19:51

I try to parse a XML-file with the following structure:


  
     
        

        
3条回答
  •  执笔经年
    2021-02-09 20:34

    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();
        }
    }
    

提交回复
热议问题