Results 1 to 1 of 1
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 ...
- 07-24-2010 #1
[C] Help with libxml2 and comment creation
I'm trying to create xml tree like this
My problem is the comment, here is my code:Code:<?xml version="1.0" encoding="UTF-8"?> <!-- here is your comment --> <root>hello</root>
Anyone know how to add a comment before the "root" node? ThanksCode: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();


Reply With Quote