先找到table节点,假设叫tableNode
tableNode.Attributes.Append(doc.CreateAttribute("border"));
tableNode.Attributes["border"].Value="1";

解决方案 »

  1.   

    XmlElement.SetAttribute 方法  [C#]请参见[C#] 
    using System;
    using System.IO;
    using System.Xml;public class Sample
    {
      public static void Main()
      {    XmlDocument doc = new XmlDocument();
        doc.LoadXml("<book xmlns:bk='urn:samples' bk:ISBN='1-861001-57-5'>" +
                    "<title>Pride And Prejudice</title>" +
                    "</book>");    XmlElement root = doc.DocumentElement;    // Add a new attribute.
        root.SetAttribute("genre", "urn:samples", "novel");    Console.WriteLine("Display the modified XML...");
        Console.WriteLine(doc.InnerXml);  }
    }