PDA

View Full Version : Setting the text in QDomElement



dpatel
4th May 2010, 12:56
Hi,

I want to write XML file using QDomDocument. Firstly I am creating a document and then creating an element. The tagname() of the element is set, but am not able to set the text of the element. Is there any way I can do that.

Thanks

Lykurg
4th May 2010, 13:12
Is there any way I can do that.
Yes, by reading the documentation for QDomDocument for example;) At the end of the detailed description you found
QDomDocument doc("MyML");
QDomElement root = doc.createElement("MyML");
doc.appendChild(root);

QDomElement tag = doc.createElement("Greeting");
root.appendChild(tag);

QDomText t = doc.createTextNode("Hello World");
tag.appendChild(t);

QString xml = doc.toString();
That should answer your question: QDomText!