Here you can find the source of getAttributeValueByName(NamedNodeMap nnm, String name)
Parameter | Description |
---|---|
nnm | NamedNodeMap |
name | String |
public static String getAttributeValueByName(NamedNodeMap nnm, String name)
//package com.java2s; //License from project: LGPL import org.w3c.dom.*; public class Main { /**//w w w.ja v a2 s. c om * Searches throgh the passed NamedNodeMap for an attribute and returns it if it is found. * If it is not found, returns a null. * @param nnm NamedNodeMap * @param name String * @return String */ public static String getAttributeValueByName(NamedNodeMap nnm, String name) { for (int i = 0; i < nnm.getLength(); i++) { Attr attr = (Attr) nnm.item(i); if (attr.getName().equalsIgnoreCase(name)) { return attr.getValue(); } } return null; } /** * Returns the attribute value for the passed name in the passed node. * @param node the node to get the attribute from * @param name the name of the attribute * @return The attribute value or null if it is not found. */ public static String getAttributeValueByName(Node node, String name) { return getAttributeValueByName(node.getAttributes(), name); } }