Here you can find the source of setAttributeValue(Node sNode, String attribName, String val)
Parameter | Description |
---|---|
sNode | a parameter |
attribName | a parameter |
val | a parameter |
public static void setAttributeValue(Node sNode, String attribName, String val)
//package com.java2s; import org.w3c.dom.Node; public class Main { /**//from w ww. ja v a 2s . c om * Utility method to set the attribute value on the given * element node * * @param sNode * @param attribName * @param val */ public static void setAttributeValue(Node sNode, String attribName, String val) { Node attr = sNode.getAttributes().getNamedItem(attribName); if (attr != null) { attr.setNodeValue(val); } else { attr = sNode.getOwnerDocument().createAttribute(attribName); attr.setNodeValue(val); sNode.getAttributes().setNamedItem(attr); } } }