1

I have a reference to an xml_node. Is there a way to change it to be a comment type node (node_comment)? Essentially to comment the node out.

ilya1725
  • 4,496
  • 7
  • 43
  • 68

1 Answers1

1

For converting an element into a comment, you'd want to use something along these lines:

std::ostringstream oss;
node.print(oss, "", pugi::format_raw);

auto comment = node.parent().insert_child_before(pugi::node_comment, node);
comment.set_value(oss.str().c_str());

node.parent().remove_child(node);
ilya1725
  • 4,496
  • 7
  • 43
  • 68