Here you can find the source of addAttribute(Node parent, String name, String value)
public static Attr addAttribute(Node parent, String name, String value)
//package com.java2s; //License from project: Open Source License import org.w3c.dom.Attr; import org.w3c.dom.Node; public class Main { public static Attr addAttribute(Node parent, String name, String value) { if (value == null) return null; Attr node = parent.getOwnerDocument().createAttribute(name); try {// ww w . ja v a 2 s.com node.setValue(value); parent.getAttributes().setNamedItem(node); } catch (Exception e) { System.out.println("Problem rewriting " + parent.getNodeName() + "." + name + "='" + node.getValue() + "' -> '" + value + "'"); } return node; } }