using System;
using System.IO;
using System.Xml;public class Sample
{
public static void Main()
{ XmlDocument doc = new XmlDocument();
doc.LoadXml("<book genre='novel' ISBN='1-861001-57-5'>" +
"<title>Pride And Prejudice</title>" +
"</book>"); XmlNode root = doc.DocumentElement; //Create a new node.
XmlElement elem = doc.CreateElement("price");
elem.InnerText="19.95"; //Add the node to the document.
root.AppendChild(elem); Console.WriteLine("Display the modified XML...");
doc.Save(Console.Out); }
}我知道这样可以扩充跟节点,但是怎么在跟节点下面继续添加节点呢,请指教
using System.IO;
using System.Xml;public class Sample
{
public static void Main()
{ XmlDocument doc = new XmlDocument();
doc.LoadXml("<book genre='novel' ISBN='1-861001-57-5'>" +
"<title>Pride And Prejudice</title>" +
"</book>"); XmlNode root = doc.DocumentElement; //Create a new node.
XmlElement elem = doc.CreateElement("price");
elem.InnerText="19.95"; //Add the node to the document.
root.AppendChild(elem); Console.WriteLine("Display the modified XML...");
doc.Save(Console.Out); }
}我知道这样可以扩充跟节点,但是怎么在跟节点下面继续添加节点呢,请指教
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货