Java XML Element Get getElementAsFloat(Element e, String name, Float dft)

Here you can find the source of getElementAsFloat(Element e, String name, Float dft)

Description

get Element As Float

License

Open Source License

Declaration

public static Float getElementAsFloat(Element e, String name, Float dft) 

Method Source Code


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

import org.w3c.dom.Element;

public class Main {
    public static Float getElementAsFloat(Element e, String name, Float dft) {
        String num = getElement(e, name);
        return num.equals("") ? dft : Float.parseFloat(num);
    }/*from   w w  w .  j av  a 2  s  . c om*/

    public static String getElement(Element e, String name) {
        if (e.getElementsByTagName(name) == null)
            return "";
        if (e.getElementsByTagName(name).item(0) == null)
            return "";
        return e.getElementsByTagName(name).item(0).getTextContent();
    }
}

Related

  1. getElement(Element root, String name)
  2. getElement(final Document doc, final String expression)
  3. getElement(SOAPMessage message, String tagname, String nsURI, int whichOne)
  4. getElementArray(Element config, String elementName)
  5. getElementAsBoolean(Element e, String name)
  6. getElementAsInt(Element element)
  7. getElementAttributeValue(Document doc, String tagName, String attributeName)
  8. getElementBooleanValue(Document document, Element parent, String element)
  9. getElementByClass(Element ele, String name)