Wrong output when printing document with modified value
Brought to you by:
kaalus
Printing a document having a node with a modified value yields the wrong output. Example:
xml_document<char> doc;
doc.parse<0>(doc.allocate_string("<test>old</test>"));
doc.first_node()->value(doc.allocate_string("new"));
rapidxml::print(cout, doc);
This will print "<test>old</test>" and not "<test>new</test>" as you would expect.
This is by design, although a little awkward.
The problem is that value of node is only a "shortcut" for the real data, which is stored in child data nodes of the node.
Child data nodes always take precedence over "value" of a node - to change the data you must do either one of the following:
- change the data in child data node(s), not in the value of parent node
- tell parser that you do not want to have data nodes generated (parse_no_data_nodes), in which case you can just change the value
This is by design, although admittedly a little awkward.
The problem is that value of node is only a "shortcut" for the real data,
which is stored in child data nodes of the node.
Child data nodes always take precedence over "value" of a node - to change
the data you must do either one of the following:
- change the data in child data node(s), not in the value of parent node
- tell parser that you do not want to have data nodes generated
(parse_no_data_nodes), in which case you can just change the value