如何通过C#为xml添加注释 
比如:
<?xml version="1.0" standalone="yes" ?>
<NewDataSet>
          <Table1>
<OrderID>E-Order-f1de490b-b39c-45d4-a423-1349ac3f965c</OrderID>
<ProviderID>1</ProviderID>
<ReturnReasonID>1</ReturnReasonID>
</Table1>
</NewDataSet>通过代码让它变成
<?xml version="1.0" standalone="yes" ?>
<!-- aaaaa -->
<!-- bbbbb -->
<NewDataSet>
          <Table1>
<OrderID>E-Order-f1de490b-b39c-45d4-a423-1349ac3f965c</OrderID>
<ProviderID>1</ProviderID>
<ReturnReasonID>1</ReturnReasonID>
</Table1>
</NewDataSet>如何实现?? 谢谢~~~~

解决方案 »

  1.   

    参考:
    XmlDocument.CreateComment Method 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>");    //Create a comment.
        XmlComment newComment;
        newComment = doc.CreateComment("Sample XML document");    //Add the new node to the document.
        XmlElement root = doc.DocumentElement;
        doc.InsertBefore(newComment, root);    Console.WriteLine("Display the modified XML...");        
        doc.Save(Console.Out);  }
    }