Java XML Attribute Get getAttributValue(Node n, String name)

Here you can find the source of getAttributValue(Node n, String name)

Description

get Attribut Value

License

BSD License

Declaration

public static String getAttributValue(Node n, String name) 

Method Source Code

//package com.java2s;
//License from project: BSD License 

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

public class Main {
    public static String getAttributValue(Node n, String name) {
        if (n == null)
            return null;
        NamedNodeMap att = n.getAttributes();
        if (att == null)
            return null;
        Node n2 = att.getNamedItem(name);
        if (n2 == null)
            return null;
        return n2.getNodeValue();
    }/*from   ww w . j ava  2 s .  c  om*/

    public static String getNodeValue(Node n) {
        if (n == null)
            return null;
        return n.getTextContent();
    }
}

Related

  1. getAttributeValuePair(Node node)
  2. getAttributeValues(Element el)
  3. getAttributeValues(Node node, String nodeName, String attrName)
  4. getAttributeWithInheritance(Element element, String attributeName)
  5. getAttributName(Node node)
  6. getAttrInt(Element root, String attrName)
  7. getAttrList(Node node)
  8. getAttrName(String prefix, String name)
  9. getAttrNS(Node node, String nameSpace, String attrName)