如:xml文件:
<?xml version="1.0" encoding="utf-8"?>
<what>
  <Re ID="1" max="">
    <UserID>www</UserID>
    <DateTime>2006-11-22 09:25:06</DateTime>
    <IP>192.168.1.17</IP>
  </Re>
</what>
怎样删除Re节点的max属性???(是删除此属性,不是清空属性值!!!)
好像有个Attributes.Remove方法,怎么用???

解决方案 »

  1.   

    public void DeleteRow()
        {
            string strXMLPath = Server.MapPath("xml文件");
            XmlDocument xmldoc = new XmlDocument();
            xmldoc.Load(strXMLPath);
            XmlNode _node = xmldoc.SelectSingleNode("what/Re[UserID='www']");
            if (_node != null)
            {
                _node.ParentNode.RemoveChild(_node);
            }
            xmldoc.Save(strXMLPath);
        }
      

  2.   

    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>");    XmlElement root = doc.DocumentElement;    // Remove the genre attribute.
        root.RemoveAttribute("genre");
        
        Console.WriteLine("Display the modified XML...");
        Console.WriteLine(doc.InnerXml);  }
    }
      

  3.   

    俺要删除Re节点的max属性,不是整个Re节点阿。要这样的结果:
    <Re ID="1">
    <UserID>www</UserID>
    <DateTime>2006-11-22 09:25:06</DateTime>
    <IP>192.168.1.17</IP>
    </Re>
      

  4.   

    XmlElement xe=....;
    xe.RemoveAttribute("ID");//删除ID属性