Here you can find the source of getAttributeValue(Element elem, String name)
Parameter | Description |
---|---|
elem | the element containing the attribute |
name | the name of the attribute |
public static String getAttributeValue(Element elem, String name)
//package com.java2s; /* NOTICE: This file has been changed by Plutext Pty Ltd for use in docx4j. * The package name has been changed; there may also be other changes. * //from w w w. j a va2s. c o m * This notice is included to meet the condition in clause 4(b) of the License. */ import org.w3c.dom.Attr; import org.w3c.dom.Element; public class Main { /** * Returns the attribute value for the attribute with the specified name. * Returns null if there is no such attribute, or * the empty string if the attribute value is empty. * * <p>This works around a limitation of the DOM * <code>Element.getAttributeNode</code> method, which does not distinguish * between an unspecified attribute and an attribute with a value of * "" (it returns "" for both cases). * * @param elem the element containing the attribute * @param name the name of the attribute * @return the attribute value (may be null if unspecified) */ public static String getAttributeValue(Element elem, String name) { Attr attr = elem.getAttributeNodeNS(null, name); return (attr == null) ? null : attr.getValue(); } }