Java XML Attribute Add addAttribute(final Node node, final Attr attribute)

Here you can find the source of addAttribute(final Node node, final Attr attribute)

Description

add Attribute

License

Apache License

Declaration

public static final void addAttribute(final Node node, final Attr attribute) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import org.w3c.dom.Attr;

import org.w3c.dom.Node;

public class Main {
    public static final void addAttribute(final Node node, final Attr attribute) {
        if (node != null) {
            node.getAttributes().setNamedItem(attribute);
        }/*from  w  ww. ja  v  a 2 s . c o  m*/
    }

    public static final void addAttribute(final Node node, final String name, final Attr attribute) {
        if (node != null) {
            final String nodeName = node.getNodeName();
            if (nodeName != null && nodeName.equals(name)) {
                node.getAttributes().setNamedItem(attribute);
            }
        }
    }
}

Related

  1. addAttribute(Element elem, String name, String value)
  2. addAttribute(final AttributesImpl attributes, final String localName, final Object value)
  3. addAttribute(final Document doc, final Element parent, final String name, final String value)
  4. addAttribute(final Element element, final String attributeName, final String value)
  5. addAttribute(final Node e, final String name, final String value)
  6. addAttribute(Node parent, String name, String value)
  7. addAttribute(Node pNode, String attrName, String attrValue)
  8. addAttributes(Element element, String[][] attributes)
  9. addAttributeToXPathExpression(Node nodeAttr, String xpathExpression, String and)