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中删除“”部分。
答案 0 :(得分:1)
只需忽略对xmlTextWriterStartDocument
的调用即可。请注意,您仍然必须致电xmlTextWriterEndDocument
。