QFile file("Init.xml");
if(!file.open(QFile::ReadOnly))
return;

QDomDocument doc;
if(!doc.setContent(&file))
{
file.close();
return;
}
file.close();

QDomElement root=doc.documentElement();
if(!root.childNodes().isEmpty())
{
for(int i=0;i<11;i++)
{
QDomNode node= root.childNodes().at(2).childNodes().at(i);//就这是重点
node.firstChild().setNodeValue("null");
if(str[i].size()>0)
{
QDomNode node= root.childNodes().at(2).childNodes().at(i);
node.firstChild().setNodeValue(str[i]);
}

}

if(!file.open(QFile::WriteOnly|QFile::Truncate))
return;
//操作完成存进文件
QTextStream out_stream(&file);
doc.save(out_stream,4);
file.close();
}

这里for循环里面就是读XML的步骤 读到拿QDomNode temp存一下。setNodeValue就修改了内容了