Java XML Attribute Remove removeAttribute(Node node, String attr)

Here you can find the source of removeAttribute(Node node, String attr)

Description

Removes a named attribute of a Node

License

Open Source License

Parameter

Parameter Description
node The node to search
attr The name of the attribute to remove

Declaration

public synchronized static void removeAttribute(Node node, String attr) 

Method Source Code


//package com.java2s;
import org.w3c.dom.*;

public class Main {
    /**/*from   w  ww.ja v  a2s .  c om*/
     *  Removes a named attribute of a Node<p>
     *  @param node The node to search
     *  @param attr The name of the attribute to remove
     */
    public synchronized static void removeAttribute(Node node, String attr) {
        if (node == null)
            throw new IllegalArgumentException("Node argument cannot be null");
        if (attr == null)
            throw new IllegalArgumentException("Node attribute argument cannot be null");

        NamedNodeMap map = node.getAttributes();
        if (map != null) {
            Node an = map.getNamedItem(attr);
            if (an != null)
                map.removeNamedItem(attr);
        }
    }
}

Related

  1. removeAttribute(final Node iNode, final String iAttributeName)
  2. removeAttribute(final Node node, final String name)
  3. removeAttribute(Node iNode, String iAttributeName)
  4. removeAttribute(Node iNode, String iAttributeName)
  5. removeAttribute(Node node, String attName)
  6. removeAttribute(Node node, String attrName)
  7. removeAttribute(Node node, String... attributs)
  8. removeAttribute(Node parent, String name, String value, boolean recursive)
  9. removeAttributeIgnoreCase(Element element, String attributeName)