Java tutorial
//package com.java2s; //License from project: Apache License import org.w3c.dom.*; public class Main { public static boolean setAttributeValue(final Element target, final String attributeName, final String value) { final NamedNodeMap map = target.getAttributes(); final Node attributeValueHolder = map.getNamedItem(attributeName); if (attributeValueHolder != null) { attributeValueHolder.setNodeValue(value); return true; } return false; } }