Parse Boolean value from Element text content - Android XML

Android examples for XML:XML Element

Description

Parse Boolean value from Element text content

Demo Code


import java.util.UUID;
import java.util.logging.Level;
import org.w3c.dom.Element;

public class Main{
    public static boolean ParseBoolean(Element e) {
        boolean value = false;
        try {/* w  w  w.  j a va2  s.  co m*/
            value = Boolean.parseBoolean(e.getTextContent().trim());
        } catch (Exception ex) {
            Log.log("Preferences.loadXMLFile(): An Exception occured while parsing the boolean '"
                    + e.getNodeName()
                    + "'. value="
                    + e.getTextContent().trim(), Level.INFO);
        }
        return value;
    }
}

Related Tutorials