Tag: xml namespaces

C#,XML,添加新节点

我正在尝试将新节点添加到现有XML文件中。 我有这个文件,其中包含第一个测试元素: test test 0 test test 我使用此模式生成此XML文档 现在,我需要添加新节点 test2 test2 到目前为止我试过这个: XmlDocument xmldoc = new XmlDocument(); xmldoc.Load(Server.MapPath(“data/sve.xml”)); XmlNode root = xmldoc.SelectSingleNode(“root/profesori”, null); XmlNode prof = xmldoc.CreateNode(XmlNodeType.Element, “profesor”, null); XmlNode ime = xmldoc.CreateNode(XmlNodeType.Element, “ime”, null); ime.InnerText = name; prof.AppendChild(ime); XmlNode prezime = xmldoc.CreateNode(XmlNodeType.Element, “prezime”, null); prezime.InnerText = surname; prof.AppendChild(prezime); root.AppendChild(prof); xmldoc.Save(Server.MapPath(“data/sve.xml”)); 我还尝试添加命名空间menager: XmlNamespaceManager nsMgr = […]