Here you can find the source of addAttribute(Document doc, Element node, String name, String value)
public static void addAttribute(Document doc, Element node, String name, String value)
//package com.java2s; import org.w3c.dom.Attr; import org.w3c.dom.Document; import org.w3c.dom.Element; public class Main { public static void addAttribute(Document doc, Element node, String name, String value) { Attr attribute = doc.createAttribute(name); attribute.setValue(value);//w w w . j a v a 2s . c o m node.getAttributes().setNamedItem(attribute); } }