我需要编辑 QDomElement 的文本 - 例如
我有一个 XML 文件,其内容为 -
<root>
<firstchild>Edit text here</firstchild>
</root>
如何编辑子元素的文本<firstchild>
?
我在 Qt 4.7 中提供的 QDomDocument 类描述的 QDomElement 中看不到任何函数
Edit1 - 我正在添加更多细节。
我需要阅读、修改和保存一个 xml 文件。文件的格式如下 -
<root>
<firstchild>Edit text here</firstchild>
</root>
需要编辑元素的值。我读取xml文件的代码是-
QFile xmlFile(".\\iWantToEdit.xml"); xmlFile.open(QIODevice::ReadWrite); QByteArray xmlData(xmlFile.readAll()); QDomDocument doc; doc.setContent(xmlData);
// 读取必要的值
// 写回修改后的值?
注意:我尝试将 QDomElement 转换为 QDomNode 并使用函数 setNodeValue()。然而,它不适用于 QDomElement。
我们非常欢迎任何建议、代码示例、链接。