Java XML Attribute Get getAttributeValue(Node node, String attName)

Here you can find the source of getAttributeValue(Node node, String attName)

Description

get Attribute Value

License

Open Source License

Declaration

public static String getAttributeValue(Node node, String attName) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;

public class Main {
    public static String getAttributeValue(Node node, String attName) {
        if (attName == null || attName.trim().length() == 0) {
            return null;
        }/*from w  ww  .  j  a v a2s.c  o  m*/
        NamedNodeMap attMap = node.getAttributes();

        for (int index = 0; index < attMap.getLength(); index++) {
            Node aNode = attMap.item(index);
            String aName = aNode.getNodeName();
            if (attName.equals(aName)) {
                return aNode.getNodeValue();
            }
        }
        return null;
    }
}

Related

  1. getAttributeValue(Node htmlForm, String attributeName)
  2. getAttributeValue(Node iNode, String iAttributeName)
  3. getAttributeValue(Node n, String name)
  4. getAttributeValue(Node n, String name)
  5. getAttributeValue(Node n, String nodePath, String attrName)
  6. getAttributeValue(Node node, String attName)
  7. getAttributeValue(Node node, String attribute)
  8. getAttributeValue(Node node, String attribute)
  9. getAttributeValue(Node node, String attribute)