Java tutorial
//package com.java2s; import org.w3c.dom.Element; import org.w3c.dom.NodeList; public class Main { static Boolean getBooleanValue(Element ele, String tagName) { String value = getTextValue(ele, tagName); // LOGGER.info("tagName: |" + tagName + "|"); // LOGGER.info("value: " + value); if (value != null) { if (isBoolean(value)) return Boolean.valueOf(value); } return null; } public static String getTextValue(Element ele, String tagName) { String textVal = null; Element el = getChildElement(ele, tagName); if (el != null) textVal = el.getFirstChild().getNodeValue(); return textVal; } public static boolean isBoolean(String string) { try { Boolean.valueOf(string); return true; } catch (NumberFormatException e) { return false; } } public static Element getChildElement(Element parent, String childTagName) { Element el = null; NodeList nl = parent.getElementsByTagName(childTagName); if (nl != null && nl.getLength() > 0) { el = (Element) nl.item(0); } return el; } }