Mega Code Archive

 
Categories / VB.Net Tutorial / XML
 

Remove an attribute from the document

Imports System Imports System.IO Imports System.Xml public class Sample   public shared sub Main()     Dim doc as XmlDocument = new XmlDocument()     doc.LoadXml("<book genre='novel' ISBN='11111111111'>" & _                 "<title>AAA</title>" & _                 "</book>")           'Create an attribute collection and remove an attribute     'from the collection.       Dim attrColl as XmlAttributeCollection = doc.DocumentElement.Attributes     attrColl.Remove(attrColl.ItemOf("genre"))     Console.WriteLine("Display the modified XML...")     Console.WriteLine(doc.OuterXml)   end sub end class