Here you can find the source of getAttributeString(Node node, String name)
Parameter | Description |
---|---|
node | Node The context node. |
name | String |
public static String getAttributeString(Node node, String name)
//package com.java2s; /*// ww w .j av a 2s.co m Copyright (c) 2013 eBay, Inc. This program is licensed under the terms of the eBay Common Development and Distribution License (CDDL) Version 1.0 (the "License") and any subsequent version thereof released by eBay. The then-current version of the License can be found at http://www.opensource.org/licenses/cddl1.php and in the eBaySDKLicense file that is under the eBay SDK ../docs directory. */ import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; public class Main { /** * Gets the value of a named attribute of a node. * @param node Node The context node. * @param name String * @return String null means node is not found. */ public static String getAttributeString(Node node, String name) { Node nd = findAttribute(node, name); if (nd != null) return nd.getNodeValue(); return null; } /** * Finds attribute of node by name. * @param node Node The context node. * @param name String * @return Node */ public static Node findAttribute(Node node, String name) { Node found = null; NamedNodeMap nm = node.getAttributes(); if (nm != null) { for (int i = 0; i < nm.getLength(); i++) { Node attr = nm.item(i); if (attr.getNodeName().compareToIgnoreCase(name) == 0) { found = attr; break; } } } return found; } }