Here you can find the source of addAttribute(Document doc, Element parent, String attribute, Object value)
public static Attr addAttribute(Document doc, Element parent, String attribute, Object value)
//package com.java2s; import org.w3c.dom.*; public class Main { public static Attr addAttribute(Document doc, Element parent, String attribute, Object value) { Attr attr = doc.createAttribute(attribute); attr.setValue(String.valueOf(value)); parent.setAttributeNode(attr);/*from ww w .j a v a 2 s . com*/ return attr; } }