Android XML Node Attribute Get getElementAttr(Node element, String attrName)

Here you can find the source of getElementAttr(Node element, String attrName)

Description

get Element Attr

Declaration

public static String getElementAttr(Node element, String attrName) 

Method Source Code

//package com.java2s;

import org.w3c.dom.Node;

public class Main {
    public static String getElementAttr(Node element, String attrName) {
        if (element.getAttributes() != null) {
            for (int i = 0; i < element.getAttributes().getLength(); i++) {
                Node child = element.getAttributes().item(i);
                if (child.getNodeName().equals(attrName)) {
                    return child.getNodeValue();
                }// www. j a va2s.  c  o m
            }
        }

        return null;
    }
}

Related

  1. getAttrOfName(Node node, String string)
  2. getAttribute(Node node, String name)
  3. getAttributeValue(Node node, String attributeName)
  4. getAttributeValue(Node node, String attributeName)
  5. getAttributeValueAsInt(Node node, String attributeName)
  6. getElementAttr(Node element, String attrName)
  7. getElementIntAttr(Node element, String attrName)
  8. getElementIntAttr(Node element, String attrName)
  9. getEnumAttribute(Node archiveNode, String attrName, Object[] values, Object defaultValue)