Here you can find the source of getAttribute(String key, NamedNodeMap map)
Parameter | Description |
---|---|
key | the name of the attribute. |
map | the named node map with the attribute key/value pairs. |
public static String getAttribute(String key, NamedNodeMap map)
//package com.java2s; //License from project: Open Source License import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; public class Main { /**/*w w w. ja v a 2s. co m*/ * Gets the attribute as a string. * @param key the name of the attribute. * @param map the named node map with the attribute key/value pairs. * @return the attribute value or an empty string if it does not exist. */ public static String getAttribute(String key, NamedNodeMap map) { Node attr = map.getNamedItem(key); return attr != null ? attr.getTextContent() : ""; } }