XmlElement root = xmlDocument.CreateElement("root");
xmlDocument.AppendChild(root);
我要在一个空的XML文档中创建一个根元素,但是执行以上代码之后,文档里的内容却是</root>,请问是怎么回事?
xmlDocument.AppendChild(root);
我要在一个空的XML文档中创建一个根元素,但是执行以上代码之后,文档里的内容却是</root>,请问是怎么回事?
最好先添加xml定义
xmlDocument.AppendChild(xmlDocument.CreateXmlDeclaration("1.0", "UTF-8", null));