Java XML Attribute Get getAttribute(Node node, String localName, String namespaceURI)

Here you can find the source of getAttribute(Node node, String localName, String namespaceURI)

Description

get Attribute

License

Open Source License

Declaration

public static String getAttribute(Node node, String localName, String namespaceURI) 

Method Source Code

//package com.java2s;

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

public class Main {
    public static String getAttribute(Node node, String name) {
        NamedNodeMap attributes = node.getAttributes();
        if (attributes == null) {
            return null;
        }/* w w w.jav a  2 s .co  m*/

        Node attributeNode = node.getAttributes().getNamedItem(name);
        if (attributeNode == null) {
            return null;
        }
        return attributeNode.getTextContent();
    }

    public static String getAttribute(Node node, String localName, String namespaceURI) {
        Node attributeNode = node.getAttributes().getNamedItemNS(namespaceURI, localName);
        if (attributeNode == null) {
            return null;
        }
        return attributeNode.getTextContent();
    }
}

Related

  1. getAttribute(Node node, String attributeName)
  2. getAttribute(Node node, String attributeName)
  3. getAttribute(Node node, String attributeName)
  4. getAttribute(Node node, String attributeName, String defaultValue)
  5. getAttribute(Node node, String attrName)
  6. getAttribute(Node node, String localName, String namespaceURI)
  7. getAttribute(Node node, String name)
  8. getAttribute(Node node, String name)
  9. getAttribute(Node node, String name)