Java tutorial
//package com.java2s; import org.w3c.dom.*; public class Main { private static void addAttribute(Document doc, Element root, String param, String value) { Attr attr = doc.createAttribute(param); attr.setValue(value); root.setAttributeNode(attr); } }