比如我需要创建这样一个文件。
<Log>
  <Message>this is a message </Message>
  <ID>111</ID>
  <Type>Crash</Type>
</Log>
我如何在这样结构的一个XML文件末尾增加一个新的节点呢?谢谢

解决方案 »

  1.   

    http://blog.csdn.net/lizanhong/archive/2004/06/23/24374.aspx
      

  2.   

    net_lover(孟子E章): 谢谢你。
    但csdn的blog打不开阿!
      

  3.   

    ms-help://MS.MSDNQTR.2003FEB.2052/cpref/html/frlrfSystemXmlXmlNodeClassAppendChildTopic.htm 下面的示例将一个新节点添加到 XML 文档。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);  }
    }