Java XML Attribute Set setAttribute(Node node, String key, String value)

Here you can find the source of setAttribute(Node node, String key, String value)

Description

set Attribute

License

Open Source License

Parameter

Parameter Description
node a parameter
key a parameter
value a parameter

Declaration

public static void setAttribute(Node node, String key, String value) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import org.w3c.dom.Node;

public class Main {

    public static void setAttribute(Node node, String key, String value) {
        Node attributeNode = node.getOwnerDocument().createAttribute(key);
        attributeNode.setNodeValue(value);

        node.getAttributes().setNamedItem(attributeNode);
    }//from  w  w  w  .  ja  v a 2  s .  c  o  m
}

Related

  1. setAttribute(final Element element, final String attrName, final Object value)
  2. setAttribute(final Element element, final String name, final String value)
  3. setAttribute(Node n, String name, String value)
  4. setAttribute(Node node, String attName, String val)
  5. setAttribute(Node node, String attr, String value)
  6. setAttribute(Node pNode, String attrName)
  7. setAttribute(String name, String value, Element el)
  8. setAttributeNS(Element node, String namespaceURI, String prefix, String nodeName, String value)
  9. setAttributeValue(Element element, String attribute, String value)