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.

1 Answer 1

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);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.