static void CreateXML(string outputPath)
{
XmlDocument _xmlDoc = new XmlDocument();
string _xmlNode = @"<books type='ITP' language='english'><metadata></metadata></books>";
_xmlDoc.LoadXml(_xmlNode);
XmlDeclaration _xmlDeclar = _xmlDoc.CreateXmlDeclaration("1.0", "UTF-8", "no");
XmlElement _root = _xmlDoc.DocumentElement;
_xmlDoc.InsertBefore(_xmlDeclar, _root);
if (!string.IsNullOrWhiteSpace(outputPath))
{
_xmlDoc.Save(outputPath);
}
}

文档预览

<?xml version="1.0" encoding="utf-8" standalone="no"?>
<books type="ITP" language="english">
<metadata>
</metadata>
</books>
05-08 08:08