#3 Wrong output when printing document with modified value

closed-wont-fix
nobody
None
5
2014-07-13
2009-01-27
Anonymous
No

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.

Discussion

  • Nobody/Anonymous

    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

     
  • mack

    mack - 2009-02-02
    • status: open --> closed-wont-fix
     
  • mack

    mack - 2009-02-02

    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

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks