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

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

Description

get Attrib As Float

License

Open Source License

Declaration

public static Float getAttribAsFloat(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 getAttribAsFloat(Element e, String name, Float dft) {
        String num = getAttribute(e, name);
        return num.equals("") ? dft : Float.parseFloat(num);
    }//from ww w . ja  va 2s .co m

    public static String getAttribute(Element e, String name) {
        if (e.getAttribute(name) == null)
            return "";
        return e.getAttribute(name);
    }
}

Related

  1. getAttr(Node node, String name, String defaultValue)
  2. getAttrBool(Node n, String name)
  3. getAttrDate(Element elem, String localName)
  4. getAttrib(NamedNodeMap attribs, String name)
  5. getAttribAsBoolean(Element e, String name, Boolean dft)
  6. getAttribBoolean(Element ele, String name)
  7. getAttribByName(Element node, String name)
  8. getAttribFloat(Element ele, String name)
  9. getAttribIntHex(Element ele, String name)