Th3Ya0vi / pugixml

Automatically exported from code.google.com/p/pugixml
0 stars 0 forks source link

Changing an empty node value #197

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Hello. I use pugixml 1.2.
When I write this simple code:

pugi::xml_document doc;
doc.load("<username></username>");
pugi::xml_node node = doc.child("username").first_child();
node.set_value("my_user_name");
cout << node.value() << endl;   

I have an empty output. How to correct this behaviour?

Original issue reported on code.google.com by egoch...@gmail.com on 21 Feb 2013 at 10:42

GoogleCodeExporter commented 8 years ago
What happens here is that first_child() returns an empty node handle; all 
operations on the empty handle do not do anything.

Since you're using pugixml 1.2, you can use the text() member that creates the 
necessary PCDATA nodes behind the scenes:
http://pugixml.googlecode.com/svn/tags/latest/docs/manual/access.html#manual.acc
ess.text
http://pugixml.googlecode.com/svn/tags/latest/docs/manual/modify.html#manual.mod
ify.text

Original comment by arseny.k...@gmail.com on 21 Feb 2013 at 3:53

GoogleCodeExporter commented 8 years ago

Original comment by arseny.k...@gmail.com on 3 Mar 2013 at 2:58