XmlDocument doc = new XmlDocument();
XmlDeclaration xmldecl;
xmldecl = doc.CreateXmlDeclaration("1.0", "UTF-8", null);
//Add the new node to the document.
XmlElement root = doc.DocumentElement;
doc.InsertBefore(xmldecl, root);
doc.AppendChild(doc.CreateElement("item", "urn:1"));
doc.PreserveWhitespace = false;
doc.Save("C:\\1.xml");
本文介绍了使用XMLDocument创建XML文档、添加XML声明、插入节点、追加元素、保存文件的基本操作。
5072

被折叠的 条评论
为什么被折叠?



