Java XML Attribute Remove removeAllAttributes(Element element)

Here you can find the source of removeAllAttributes(Element element)

Description

remove All Attributes

License

Open Source License

Declaration

public static void removeAllAttributes(Element element) 

Method Source Code

//package com.java2s;

import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Attr;
import org.w3c.dom.Element;

public class Main {
    public static void removeAllAttributes(Element element) {
        // A NamedNodeMap is live.
        NamedNodeMap attrs = element.getAttributes();
        int attrCount = attrs.getLength();

        for (int i = attrCount - 1; i >= 0; --i) {
            Attr attr = (Attr) attrs.item(i);

            attrs.removeNamedItemNS(attr.getNamespaceURI(), attr.getLocalName());
        }/*from  w ww.jav a  2 s . c  o  m*/
    }
}

Related

  1. removeAllAttributes(Element element)
  2. removeAllAttributes(Element element)
  3. removeAllAttributes(Node node, String attrName)
  4. removeAllSubNodesExceptAttributes(Node n)
  5. removeAttribute(Element elem, String name)
  6. removeAttribute(Element element, String name)