QFile probeFile ("1.xml"); if( probeFile.open(QIODevice::ReadOnly | QIODevice::Text) ) { QXmlStreamReader xmlReader(&probeFile); xmlReader.readNext(); while(!xmlReader.atEnd()) { if (xmlReader.isStartElement()) { if (xmlReader.name() == "description") { QString temp = xmlReader.readElementText(); qDebug() << temp; } if (xmlReader.name() == "computation_date") { QString temp = xmlReader.readElementText(); qDebug() << temp; } if (xmlReader.name() == "transformation") { QString temp = xmlReader.readElementText(); qDebug() << temp; } } xmlReader.readNext(); } }原文链接:https://www.f2er.com/xml/296046.html