I need to edit the text of a QDomElement - Eg
I have an XML file with its content as -
<root>
<firstchild>Edit text here</firstchild>
</root>
How do I edit the text of the child element <firstchild>
?
I don't see any functions in the QDomElement of QDomDocument classes descriptions provided in Qt 4.7
Edit1 - I am adding more details.
I need to read, modify and save an xml file. To format of the file is as below -
<root>
<firstchild>Edit text here</firstchild>
</root>
The value of element needs to be edited.I code to read the xml file is -
QFile xmlFile(".\iWantToEdit.xml");
xmlFile.open(QIODevice::ReadWrite);
QByteArray xmlData(xmlFile.readAll());
QDomDocument doc;
doc.setContent(xmlData);
// Read necessary values
// write back modified values?
Note: I have tried to cast a QDomElement to QDomNode and use the function setNodeValue(). It however is not applicable to QDomElement.
Any suggestions, code samples, links would we greatly welcome.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…