You are not logged in.


Thursday, September 29th 2011, 8:58am

How can change XML node value?

Hi all,

I have a xml file such as:

How can i update 100 to new value such as 50?

I can get 100 from file using QDomDocument, QDomNode, QDomElement classes and QDomElemet::text method.
But i can not update file. How can i do that? which class or function should i use to update <lm>100</lm> to </lm>50</lm>?


Thursday, September 29th 2011, 1:24pm

you have to use void QDomNode::save ( QTextStream & str, int indent ) const method..

example :

QDomNode* node = .... // retrieve the node you want to edit..
QByteArray data;
QTextStream ts(&data);

node->firstChildElement("mytag").save(ts, 2);