Here you can find the source of getAttributeValueOrNull(NamedNodeMap attributes, String attributeName)
Parameter | Description |
---|---|
attributes | the map of attributes |
attributeName | the particular attribute whose value will be returned. |
private static String getAttributeValueOrNull(NamedNodeMap attributes, String attributeName)
//package com.java2s; //License from project: Apache License import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; public class Main { /**/*from w ww . ja v a2s. co m*/ * Given a list of attributes (from an XML element) and the particular attribute we are concerned with, * return it's value. If there is no value, return NULL> * * @param attributes the map of attributes * @param attributeName the particular attribute whose value will be returned. * @return the value that corresponds to the attribute name provided. */ private static String getAttributeValueOrNull(NamedNodeMap attributes, String attributeName) { String returnValue = null; Node namedItem = attributes.getNamedItem(attributeName); if (namedItem != null) { returnValue = namedItem.getNodeValue(); } return returnValue; } }