I'm trying to create xml tree like this
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!-- here is your comment -->
<root>hello</root>
My problem is the comment, here is my code:
Code:
xmlDocPtr doc = xmlNewDoc(BAD_CAST "1.0");
/* warning! */
xmlNodePtr commentNode = xmlNewComment(BAD_CAST "here is your comment");
//xmlAddSibling(doc, commentNode); ????
xmlNodePtr root_node = xmlNewNode(NULL, BAD_CAST "root");
xmlDocSetRootElement(doc,root_node);
xmlSaveFormatFileEnc(xmlFile,doc,"UTF-8",1);
xmlFreeDoc(doc);
xmlCleanupParser();
Anyone know how to add a comment before the "root" node? Thanks