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;

import org.w3c.dom.Node;

public class Main {
    /**//from w  w  w  .j  av a2s .  co  m
     * Returns an attribute of the specified tag with the name provided.
     *
     * @param node
     * @param name
     * @return The attribute if its defined, or null.
     */
    public static String getAttribute(Node node, String name, String defVal) {
        Node att = node.getAttributes().getNamedItem(name);
        return att == null ? defVal : att.getNodeValue();
    }

    public static String getAttribute(Node node, String name) {
        return getAttribute(node, name, null);
    }
}

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)
  7. getAttribute(Node node, String name)
  8. getAttribute(Node node, String name)
  9. getAttribute(Node node, String name, String defVal)