Java examples for XML:XML Attribute
set Xml Attribute 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 ww. j a v a2 s .co m elem.getAttributes().setNamedItem(a); } }