Java XML Attribute Get getAttributeFloatValue(String attribute, NamedNodeMap namedNodeMap)

Here you can find the source of getAttributeFloatValue(String attribute, NamedNodeMap namedNodeMap)

Description

get Attribute Float Value

License

Open Source License

Declaration

public static float getAttributeFloatValue(String attribute, NamedNodeMap namedNodeMap) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;

public class Main {
    public static float getAttributeFloatValue(String attribute, NamedNodeMap namedNodeMap) {
        String value = getAttributeStringValue(attribute, namedNodeMap);
        if (value != null) {
            return Float.parseFloat(value);
        }/* w  ww  .ja  v  a 2 s  . com*/
        return 0.0f;
    }

    public static String getAttributeStringValue(String attribute, NamedNodeMap namedNodeMap) {
        Node node = namedNodeMap.getNamedItem(attribute);
        if (node != null) {
            return node.getTextContent();
        }
        return null;
    }
}

Related

  1. getAttributeByName(Node content, String attributeName)
  2. getAttributeByName(Node node, String name, boolean defaultValue)
  3. getAttributeByName(Node node, String name, String defaultValue)
  4. getAttributeContent(Node item, String attributeName)
  5. getAttributeEnum(Node node, String attributeName, Class enumClass)
  6. getAttributeFromClosestAncestorOfAnyKind(Node node, String attributeName)
  7. getAttributeIfExists(Node node, String name)
  8. getAttributeIgnoreCase(Element element, String attributeName)
  9. getAttributeIgnoreCase(Element element, String string)