I am using libxml++-2.6 in C to create a really simple XML doc.
What is the technique for adding:
- comments before the root node?
- comments inside a node?
.
root_node = xmlNewNode( NULL, BAD_CAST "root" );
xmlDocSetRootElement( doc, root_node );
dtd = xmlCreateIntSubset(doc, BAD_CAST "root", NULL, BAD_CAST "root.dtd");
// neither of these seem to work
xmlNewComment( BAD_CAST "My Company, LLC" );
xmlNewDocComment ( doc, BAD_CAST "My Company, LLC" );
Before this got moved here I had posted my own answer in StackOverflow. Sorry to post it as an answer, but you can’t do formatted inopput in comments. 🙂
This has worked for me;
Notice that as you add a node, you put the comment before it then put additional linesof comment below that comment but still before the new doc/child element.
Also notice, these comments can be outside the root node and not inside a visible node thatis a sibling of root.
e.g.