<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE CINEMAS_PROJECT_FILE>
<CinemasProject XMLversion="1">
<Cascade>
<ChildrenIDs>
<JobName>1</JobName>
<JobName>2</JobName>
<JobName>3</JobName>
</ChildrenIDs>
</Cascade>
如何使用 QXmlStreamReader 读取具有相同标记"JobName"的 XML 元素
QFile* file = new QFile(paths);
if(!file->open(QIODevice::ReadOnly | QIODevice::Text)){
qDebug() << "Failed To Open Xml";
return;
}
QXmlStreamReader* xml = new QXmlStreamReader(file);
while(!xml->atEnd()){
QXmlStreamReader::TokenType token = xml->readNext();
if(token == QXmlStreamReader::StartDocument){
continue;
}
if(xml->name() == "JobName"){
qDebug() << xml->readElementText();
}
}