Java XML Attribute Remove removeAttribute(Element elem, String name)

Here you can find the source of removeAttribute(Element elem, String name)

Description

Oracle 10i does not allow to remove an attribute that does not exist.

License

Common Public License

Declaration

public static void removeAttribute(Element elem, String name) 

Method Source Code

//package com.java2s;
/*/*from  w w w  .  java 2 s  . c  o  m*/
 * ====================================================================
 * This software is subject to the terms of the Common Public License
 * Agreement, available at the following URL:
 *   http://www.opensource.org/licenses/cpl.html .
 * Copyright (C) 2003-2004 TONBELLER AG.
 * All Rights Reserved.
 * You must accept the terms of that agreement to use this software.
 * ====================================================================
 *
 * 
 */

import org.w3c.dom.Element;

public class Main {
    /**
     * Oracle 10i does not allow to remove an attribute that does
     * not exist. This method will silently ignore any exceptions
     * that occur while removing the attribute.
     */
    public static void removeAttribute(Element elem, String name) {
        try {
            elem.removeAttribute(name);
        } catch (Exception e) {
            // ignore
        }
    }
}

Related

  1. removeAllAttributes(Element element)
  2. removeAllAttributes(Element element)
  3. removeAllAttributes(Element element)
  4. removeAllAttributes(Node node, String attrName)
  5. removeAllSubNodesExceptAttributes(Node n)
  6. removeAttribute(Element element, String name)
  7. removeAttribute(final Attr attributeNode)
  8. removeAttribute(final Node iNode, final String iAttributeName)
  9. removeAttribute(final Node node, final String name)