16,199
社区成员
发帖
与我相关
我的任务
分享
QDomDocument doc;
QFile XMLfile(fileNames);
if (XMLfile.open(QFile::ReadOnly))
{
int errorLine, errorColumn;
QString errorStr;
if (!doc.setContent(&XMLfile, false, &errorStr, &errorLine, &errorColumn))
{
return;
}
doc.normalize();
XMLfile.close();
QDomNode child = doc.documentElement().firstChild();
while (!child.isNull())
{
qDebug()<<"IPIndex = "<<child.toElement().attribute("num").toInt();
qDebug()<<"IP = "<<child.toElement().text();
child = child.nextSibling();
}
}
<?xml version='1.0' encoding='UTF-8'?>
<IP>
<p num='1'>192.168.1.1</p>
<p num='2'>192.168.1.2</p>
<p num='2'>192.168.1.3</p>
</IP>