Java XML Attribute Parse parseFloat(String attributeName, NamedNodeMap map)

Here you can find the source of parseFloat(String attributeName, NamedNodeMap map)

Description

Parses the value of the given attribute as a float.

License

Open Source License

Parameter

Parameter Description
attributeName the name of the attribute.
map the map that contains all the attributes.

Return

the float value.

Declaration

public static float parseFloat(String attributeName, NamedNodeMap map) 

Method Source Code

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

import org.w3c.dom.NamedNodeMap;

public class Main {
    /**/*from ww  w  . j  a va 2 s.  c  o  m*/
     * Parses the value of the given attribute as a float.
     * @param attributeName the name of the attribute.
     * @param map the map that contains all the attributes.
     * @return the float value.
     */
    public static float parseFloat(String attributeName, NamedNodeMap map) {
        org.w3c.dom.Node attr = map.getNamedItem(attributeName);
        try {
            return attr != null ? Float.parseFloat(attr.getTextContent()) : 0f;
        } catch (NumberFormatException ex) {
            return 0.0f;
        }
    }
}

Related

  1. parseAttributeValuePairTags(Node parentNode)
  2. parseBoolean(String xmlAttributeValue, Boolean invalidValue)
  3. parseConfigAttr(NamedNodeMap attributes)
  4. parseElementAttributes(Element element)
  5. parseFloat(Node xmlAttribute, float invalidValue)
  6. parseProtoypes(Node module, Node iFace, PrintWriter out, boolean onlyAttributes)
  7. parseString(final Element parent, final String attrName)
  8. parseString(String xmlAttributeValue, String invalidValue)