如何从xml文件中删除xml版本?

时间:2013-08-22 08:39:21

标签: libxml2

enter code here

代码部分

      xmlTextWriterPtr XMLWriter = xmlNewTextWriterFilename("example.xml",0);
      xmlTextWriterStartDocument(XMLWriter, NULL, NULL, NULL);

      xmlTextWriterStartElement(XMLWriter,BAD_CAST "Powersettings");
      xmlTextWriterSetIndent(XMLWriter,1);
      xmlTextWriterWriteElement(XMLWriter,BAD_CAST "PowerScheme",BAD_CAST "Testing");
      xmlTextWriterEndElement(XMLWriter);
      xmlTextWriterEndElement(XMLWriter);

      xmlTextWriterEndDocument(XMLWriter);
      xmlFreeTextWriter(XMLWriter);
      xmlCleanupCharEncodingHandlers();
      xmlCleanupParser();

这是我创建xml的代码,libxml2是这里使用的库。

xml contents,
<?xml version="1.0"?>
<Powersettings>
 <PowerScheme>Testing</PowerScheme>
</Powersettings>

你可以帮我解决如何从我的xml中删除“”部分。

1 个答案:

答案 0 :(得分:1)

只需忽略对xmlTextWriterStartDocument的调用即可。请注意,您仍然必须致电xmlTextWriterEndDocument