Here you can find the source of setXmlAttributeValue(Document xml, Element elem, String name, String value)
public static final void setXmlAttributeValue(Document xml, Element elem, 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 final void setXmlAttributeValue(Document xml, Element elem, String name, String value) { Attr a = xml.createAttribute(name); a.setValue(value);//from w w w. j a v a 2 s . co m elem.getAttributes().setNamedItem(a); } }