Java XML Attribute from Node getNodeAttribute(Node n, String as)

Here you can find the source of getNodeAttribute(Node n, String as)

Description

Returns the String that is the attribute of Node n named by attname or "" if that attribute doesn't exist.

License

Open Source License

Parameter

Parameter Description
n Node to query
as String naming the attribute

Declaration

public static String getNodeAttribute(Node n, String as) throws Exception 

Method Source Code


//package com.java2s;
import org.w3c.dom.Node;
import org.w3c.dom.Element;

public class Main {
    /** Returns the String that is the attribute of Node <CODE>n</CODE>
    named by <CODE>attname</CODE> or "" if that attribute doesn't exist.
    Throws an Exception if <CODE>n</CODE> isn't an Element.
        //from   w w w.  j  a v a  2 s .co  m
    @param n Node to query
    @param as String naming the attribute
    */
    public static String getNodeAttribute(Node n, String as) throws Exception {
        return ((Element) n).getAttribute(as);
    }
}

Related

  1. getLowerAttrValue(Node node, String attr)
  2. getNextSiblingElement(Node node, String elemName, String attrName, String attrValue)
  3. getNodeAttr(String attrName, Node node)
  4. getNodeAttr(String attrName, Node node)
  5. getNodeAttr(String tagName, String attrName, NodeList nodes)
  6. getNodeAttribute(Node n, String attrName)
  7. getNodeAttribute(Node n, String name)
  8. GetNodeAttribute(Node node, String attributeName)
  9. getNodeAttribute(Node node, String attributeName)