PDA

View Full Version : XML, how to set value of node



ivanotero76
17th January 2017, 13:06
Hi everyone!

I am trying to establish the value of a node like this.




QDomElement name_loc = document.createElement("Name");
document.createTextNode("Hola Mundo");
name_loc.setNodeValue("AA_upatetext");
location_init.appendChild(name_loc);



But it doesn't work.

Node is empty.

I see this link
http://www.qtcentre.org/threads/14392-how-to-modify-the-text-of-node-in-xml-docment

But I don't see clear enough.

Could you help me with this?

Added after 26 minutes:

Sorry, I already found the error.

I need to create QDomText and after appendChild to Node like:



QDomElement name_loc = document.createElement("Name");
QDomText name_loc_text = document.createTextNode(QString(def_name));
name_loc.appendChild(name_loc_text);
location_init.appendChild(name_loc);

marcos.miranda
17th January 2017, 13:11
Hi, everyone.

See this video.
I hope that help you.

https://www.youtube.com/watch?v=IrFOM0azfxQ

drbob785
20th January 2017, 02:11
Thanks for sharing the video.