Example usage for org.w3c.dom Node getAttributes

List of usage examples for org.w3c.dom Node getAttributes

Introduction

In this page you can find the example usage for org.w3c.dom Node getAttributes.

Prototype

public NamedNodeMap getAttributes();

Source Link

Document

A NamedNodeMap containing the attributes of this node (if it is an Element) or null otherwise.

Usage

From source file:Main.java

public static String getAttribute(String attribute, Node node) {
    if (null != node.getAttributes()) {
        Node attributeNode = node.getAttributes().getNamedItem(attribute);

        if (attributeNode != null) {
            return attributeNode.getNodeValue().trim();
        }/*from   ww w .ja va2  s  . c  o  m*/
    }
    return null;
}

From source file:Main.java

public static boolean getBooelanAttribute(Node node, String attributeName) {
    return node.getAttributes().getNamedItem(attributeName).getNodeValue().equals("true");
}

From source file:Main.java

static public Node getAttribute(Node node, String name) {
    return node.getAttributes().getNamedItem(name);
}

From source file:Main.java

public static String getNodeAttributeValue(Node node, String attributeName) {
    return node.getAttributes().getNamedItem(attributeName).getNodeValue();
}

From source file:Main.java

/**
 * Queries the value of an attribute of a given xml node
 *
 * @param n xml node// www  .  j av  a2  s .  co m
 * @param attribute name of the attribute
 * @return assigned value for the attribute in that node
 */
public static String getAttributeValue(Node n, String attribute) {
    return n.getAttributes().getNamedItem(attribute).getNodeValue();
}

From source file:Main.java

/**
 * Removes the given attribute from the node
 * @param doc//from   w  w w  . j a  v a2 s  .c  om
 * @param node
 * @param attrName
 */
public static void removeAttr(Node node, String attrName) {
    if (node.getAttributes().getNamedItem(attrName) != null)
        node.getAttributes().removeNamedItem(attrName);
}

From source file:Main.java

public static String getAttribute(Node node, String key) {
    Node namedItem = node.getAttributes().getNamedItem(key);
    return namedItem != null ? namedItem.getNodeValue() : null;
}

From source file:Main.java

public static String getAttributeValue(Node node, String attName) {
    Node attr = node.getAttributes().getNamedItem(attName);
    return attr.getNodeValue();
}

From source file:Main.java

public static String getAttribute(String attribute, Node node) {
    Node attributeNode = node.getAttributes().getNamedItem(attribute);

    if (attributeNode != null)
        return attributeNode.getNodeValue().trim();

    return null;//from  www  . j av  a 2 s  .co  m
}

From source file:Main.java

public static String getPath(Node node) {
    NamedNodeMap nodeMap = node.getAttributes();
    Node pathNode = nodeMap.getNamedItem("path");
    if (pathNode != null) {
        return pathNode.getNodeValue();
    } else//from   ww  w. j  a  v  a 2  s.  c o  m
        return null;
}