Java XML Attribute Get getAttributeValueAsInteger(Node node, String attributeName, Integer defaultValue)

Here you can find the source of getAttributeValueAsInteger(Node node, String attributeName, Integer defaultValue)

Description

get Attribute Value As Integer

License

Open Source License

Declaration

public static Integer getAttributeValueAsInteger(Node node, String attributeName, Integer defaultValue) 

Method Source Code


//package com.java2s;

import org.w3c.dom.Node;

public class Main {
    public static Integer getAttributeValueAsInteger(Node node, String attributeName, Integer defaultValue) {
        final Node attributeNode = node.getAttributes().getNamedItem(attributeName);

        return attributeNode != null ? Integer.parseInt(attributeNode.getTextContent()) : defaultValue;
    }/*from w  w w  .j  a  va  2 s  .  c  o m*/

    public static Integer getAttributeValueAsInteger(Node node, String attributeName) {
        final Node attributeNode = node.getAttributes().getNamedItem(attributeName);

        return attributeNode != null ? Integer.parseInt(attributeNode.getTextContent()) : null;
    }
}

Related

  1. getAttributeValue(StartElement startElement, String attributeName)
  2. getAttributeValue(String attributeName, Node xmlNode)
  3. getAttributeValueAsBoolean(Attr attribute)
  4. getAttributeValueAsBoolean(Element el, String attrName)
  5. getAttributeValueAsDouble(Node node, String attributeName)
  6. getAttributeValueAsLong(final Element el, final String attrName, final long defaultVal)
  7. getAttributeValueAsString(Node node)
  8. getAttributeValueBoolean(Node node, String attrName)
  9. getAttributeValueByName(NamedNodeMap nnm, String name)