Mega Code Archive

 
Categories / C# Tutorial / XML
 

Removes an attribute from the document

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='11111111111'>" +                 "<title>AAA</title>" +                 "</book>");           XmlAttributeCollection attrColl = doc.DocumentElement.Attributes;     attrColl.Remove(attrColl["genre"]);     Console.WriteLine("Display the modified XML...\r\n");     Console.WriteLine(doc.OuterXml);     } }