[xml] Duplicate PI nodes issue



Hi,

I have the following program below, when it runs it produces the follwing ouput
<?xml version="1.0"?>
<?xml version="1.0" encoding="UTF-8"?>

Is this a bug?
How can I work around the issue, assuming I have to support differ libxml version?

Please assume that the xml and content parameters are dynamic strings.

Best Regards
Alistair Leslie-Hughes


#include <string.h>
#include <libxml/tree.h>
#include <libxml/parser.h>
#include <libxml/xpath.h>
#include <libxml/xpathInternals.h>

int main(int argc, char* argv[])
{
   xmlDoc *doc = NULL;
   xmlNodePtr nodePI = NULL;

   xmlInitParser();

   doc = xmlNewDoc( xmlCharStrdup("1.0") );
nodePI = xmlNewPI( xmlCharStrdup("xml"), xmlCharStrdup("version=\"1.0\" encoding=\"UTF-8\""));
   xmlAddChild( (xmlNodePtr)doc, nodePI);

   xmlSaveFile("zzzzzz.xml", doc);
   xmlFreeDoc(doc);
   xmlCleanupParser();

   return 0;
}





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]