Exemplo n.º 1
0
 public virtual void RemoveAllAttributes()
 {
     if (attributes != null)
     {
         attributes.RemoveAll();
     }
 }
Exemplo n.º 2
0
    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 an attribute collection and remove all attributes
        //from the collection.
        XmlAttributeCollection attrColl = doc.DocumentElement.Attributes;

        attrColl.RemoveAll();

        Console.WriteLine("Display the modified XML...\r\n");
        Console.WriteLine(doc.OuterXml);
    }
Exemplo n.º 3
0
        public void RemoveAll()
        {
            StringBuilder xml = new StringBuilder();

            xml.Append("<?xml version=\"1.0\" ?><library><book type=\"non-fiction\" price=\"34.95\"> ");
            xml.Append("<title type=\"intro\">XML Fun</title> ");
            xml.Append("<author>John Doe</author></book></library>");

            MemoryStream memoryStream = new MemoryStream(Encoding.UTF8.GetBytes(xml.ToString()));

            document = new XmlDocument();
            document.Load(memoryStream);
            XmlNodeList            bookList   = document.GetElementsByTagName("book");
            XmlNode                xmlNode    = bookList.Item(0);
            XmlElement             xmlElement = xmlNode as XmlElement;
            XmlAttributeCollection attributes = xmlElement.Attributes;

            attributes.RemoveAll();
            Assert.AreEqual(false, xmlElement.HasAttribute("type"), "not all attributes removed.");
        }