Java tutorial
//package com.java2s; /** * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation. * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * Copyright 2011 GrossCommerce */ import org.w3c.dom.Attr; import org.w3c.dom.Element; public class Main { public static void appendIntAttribute(Element thisElement, String attrName, int value) { appendStringAttribute(thisElement, attrName, String.valueOf(value)); } public static void appendStringAttribute(Element thisElem, String attrName, String attrValue) { Attr attr = thisElem.getOwnerDocument().createAttribute(attrName); attr.setTextContent(attrValue); thisElem.setAttributeNode(attr); } }