创建XML文档结构

        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>
上一篇:uva 11374 最短路+记录路径 dijkstra最短路模板


下一篇:XML 文档结构必须从头至尾包含在同一个实体内