Java XML Attribute from Node getNodeAttribute(Node node, String s)

Here you can find the source of getNodeAttribute(Node node, String s)

Description

get Node Attribute

License

Open Source License

Declaration

public static String getNodeAttribute(Node node, String s) 

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 getNodeAttribute(Node node, String s) {
        NamedNodeMap attributes = node.getAttributes();
        for (int k = 0; k < attributes.getLength(); k++) {
            Node nodeAttr = attributes.item(k);
            if (nodeAttr.getNodeName().equals(s)) {
                return nodeAttr.getNodeValue();
            }//from  w ww. ja  v  a 2s .co m
        }
        return null;
    }
}

Related

  1. getNodeAttribute(Node node, String attributeName, String defaultValue)
  2. getNodeAttribute(Node node, String name)
  3. getNodeAttribute(Node node, String name)
  4. getNodeAttribute(Node node, String name)
  5. getNodeAttribute(Node node, String name, String def)
  6. getNodeAttribute(Node QueryNode, String AttrName)
  7. getNodeAttribute(Node thisNode, String key)
  8. getNodeAttributeAsInt(Node node, String attributeName, int defaultValue)
  9. getNodeAttributeDeep(NodeList nodelList, String nodeName, String nodeAttr)