Android XML Node Attribute Get getAttributeValue(Node node, String attributeName)

Here you can find the source of getAttributeValue(Node node, String attributeName)

Description

get Attribute Value

Declaration

static String getAttributeValue(Node node, String attributeName) 

Method Source Code

//package com.java2s;

import org.w3c.dom.Node;

public class Main {
    static String getAttributeValue(Node node, String attributeName) {
        if (node == null || attributeName == null) {
            return null;
        }//from w w  w .j a v  a 2 s. co  m
        Node attrNode = node.getAttributes().getNamedItem(attributeName);
        return attrNode != null ? attrNode.getNodeValue() : null;
    }

    static String getNodeValue(Node node) {
        return (node == null || node.getFirstChild() == null || node
                .getFirstChild().getNodeValue() == null) ? null : node
                .getFirstChild().getNodeValue().trim();
    }
}

Related

  1. getAttrOfName(Node node, String string)
  2. getAttribute(Node node, String name)
  3. getAttributeValue(Node node, String attributeName)
  4. getAttributeValueAsInt(Node node, String attributeName)
  5. getElementAttr(Node element, String attrName)
  6. getElementAttr(Node element, String attrName)
  7. getElementIntAttr(Node element, String attrName)