XmlElement elem;
elem =XmlDocument.CreateElement("新元素的前缀","新元素的本地名称","新元素的命名空间URL");
Example:
XmlDocument doc = new XmlDocument();
string xmlData = "<book xmlns:bk='urn:samples'></book>";
doc.Load(new StringReader(xmlData));
// Create a new element and add it to the document.
XmlElement elem = doc.CreateElement("bk", "genre", "urn:samples");
elem.InnerText = "fantasy";
doc.DocumentElement.AppendChild(elem);
Console.WriteLine("Display the modified XML...");
doc.Save(Console.Out);
XmlNode elem = doc.CreateNode("新节点的XmlNodeType","新节点的限定名","新节点的命名空间URL");
Example:
//Create the XmlDocument.
XmlDocument doc = new XmlDocument();
doc.LoadXml("<book genre='novel' ISBN='1-861001-57-5'>" +
"<title>Pride And Prejudice</title>" +
"</book>");
//Create a new node and add it to the document.
XmlNode elem = doc.CreateNode(XmlNodeType.Element, "price", null);
elem.InnerText = "19.95";
doc.DocumentElement.AppendChild(elem);
Console.WriteLine("Display the modified XML...");
doc.Save(Console.Out);