using System;
using System.Xml;
public class Sample { public static void Main() { XmlDocument doc = new XmlDocument();
doc.LoadXml("<book>" +
" <title>Oberon's Legacy</title>" +
" <price>5.95</price>" +
"</book>");
// Create a new element node.
XmlNode newElem;
newElem = doc.CreateNode(XmlNodeType.Element, "pages", "");
newElem.InnerText = "290";
Console.WriteLine("Add the new element to the document...");
XmlElement root = doc.DocumentElement;
root.AppendChild(newElem);
Console.WriteLine("Display the modified XML document...");
Console.WriteLine(doc.OuterXml);
}
}
using System.Xml;
public class Sample { public static void Main() { XmlDocument doc = new XmlDocument();
doc.LoadXml("<book>" +
" <title>Oberon's Legacy</title>" +
" <price>5.95</price>" +
"</book>");
// Create a new element node.
XmlNode newElem;
newElem = doc.CreateNode(XmlNodeType.Element, "pages", "");
newElem.InnerText = "290";
Console.WriteLine("Add the new element to the document...");
XmlElement root = doc.DocumentElement;
root.AppendChild(newElem);
Console.WriteLine("Display the modified XML document...");
Console.WriteLine(doc.OuterXml);
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货