Java XML Attribute Get getAttribute(Node node, String name)

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

Description

get Attribute

License

Open Source License

Declaration

public static String getAttribute(Node node, String name) 

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 getAttribute(Node node, String name) {
        NamedNodeMap attr = node.getAttributes();
        for (int n = 0; n < attr.getLength(); n++) {
            Node attribute = attr.item(n);
            if (attribute.getNodeName().equals(name))
                return attribute.getNodeValue();
        }//from   w  ww .  j av a  2s.  c o  m
        return "";
    }
}

Related

  1. getAttribute(Node node, String name)
  2. getAttribute(Node node, String name)
  3. getAttribute(Node node, String name)
  4. getAttribute(Node node, String name)
  5. getAttribute(Node node, String name)
  6. getAttribute(Node node, String name, String defVal)
  7. getAttribute(Node node, String name, String defVal)
  8. getAttribute(Node pNode, String attrName)
  9. getAttribute(Node pNode, String pName)