Java XML Element Get getElementAsBoolean(Element e, String name)

Here you can find the source of getElementAsBoolean(Element e, String name)

Description

get Element As Boolean

License

Open Source License

Declaration

public static Boolean getElementAsBoolean(Element e, String name) 

Method Source Code


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

import org.w3c.dom.Element;

public class Main {
    public static Boolean getElementAsBoolean(Element e, String name) {
        return getElementAsBoolean(e, name, false);
    }/*w  w w .  jav a2s . co  m*/

    public static Boolean getElementAsBoolean(Element e, String name, Boolean dft) {
        if (getElement(e, name) == null)
            return dft;
        else
            return Boolean.parseBoolean(getElement(e, name));
    }

    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 element, String tagName, String namespace)
  2. getElement(Element root, String name)
  3. getElement(final Document doc, final String expression)
  4. getElement(SOAPMessage message, String tagname, String nsURI, int whichOne)
  5. getElementArray(Element config, String elementName)
  6. getElementAsFloat(Element e, String name, Float dft)
  7. getElementAsInt(Element element)
  8. getElementAttributeValue(Document doc, String tagName, String attributeName)
  9. getElementBooleanValue(Document document, Element parent, String element)