为什么下面xml内添加节点的代码,不能实现呢?而且没有编译错误,但是就是不能加入新节点
void config::addnode(){
QFile file(":/linkconfig/ifisconfig.xml");
if(file.exists(":/linkconfig/ifisconfig.xml")){
QDomDocument doc;
file.open(QIODevice::ReadOnly);
doc.setContent(file.readAll());
file.close();
QDomNode root = doc.documentElement();
QDomElement subname = doc.createElement(tr("sub_name"));
QDomElement host = doc.createElement(tr("Host"));
QDomText text_host = doc.createTextNode(tr("address"));
root.appendChild(subname);
subname.appendChild(host);
host.appendChild(text_host);
file.open(QIODevice::WriteOnly);
QTextStream out(&file);
root.save(out,3);
}
else{......... }
}