1
我正在使用QT框架(v。4.7)編寫用C++編寫的小程序。將節點添加到現有的XML文檔中
我想完成的任務是打開一個現有的xml文檔,在其結構中添加一個節點並將文檔保存到之前讀取的文件中。我曾嘗試使用類似的東西:
QFile xmlIn(AFileName);
QDomDocument doc("report_1");
if (xmlIn.open(QIODevice::ReadOnly)) {
if (doc.setContent(&xmlIn)) {
QDomElement docElem = doc.documentElement();
QDomNode n = docElem.firstChild();
// Do something with the element here
n = n.nextSibling();
}
}
// Code for saving the edited QDomDocument comes here
,但我有我在這裏監督的重要組成部分的強烈的感覺,因爲這似乎是一個任務,這是非常普遍和正常的QT庫應提供一切一個可能想:d
請賜教:)
這不是附加的節點。這是重寫整個文件。 :( – phoenies 2011-06-20 08:49:06