Here you can find the source of isTrue(Element el, String tagName, boolean defaultResult)
public static boolean isTrue(Element el, String tagName, boolean defaultResult)
//package com.java2s; //License from project: Open Source License import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.w3c.dom.Text; public class Main { public static boolean isTrue(Element el, String tagName, boolean defaultResult) { Element booleanElement = getElement(el, tagName); if (booleanElement == null) { return defaultResult; } else if (isTrueText(getNestedText(booleanElement))) { return true; }/*from w ww .j a v a 2s.c o m*/ return false; } /** * returns the first element with the given name, null if none exists. */ public static Element getElement(Element config, String elementName) { NodeList children = config.getChildNodes(); for (int counter = 0; counter < children.getLength(); counter++) { if (children.item(counter) instanceof Element) { Element el = (Element) children.item(counter); if (el.getTagName().equals(elementName)) { return el; } } } return null; } public static boolean isTrueText(String nestedText) { if (nestedText.toUpperCase().equals("TRUE")) { return true; } return false; } /** returns the nested text in the tag * */ public static String getNestedText(Element config) { // logger.debug("The element name in sod util is "+config.getTagName()); String rtnValue = null; NodeList children = config.getChildNodes(); Node node; // logger.debug("The length of the children is "+children.getLength()); for (int i = 0; i < children.getLength(); i++) { node = children.item(i); if (node instanceof Text) { // logger.debug("In sodUtil textnode value is // "+node.getNodeValue()); rtnValue = node.getNodeValue(); // break; } else if (node instanceof Element) { // logger.debug("in sod util tag name is // "+((Element)node).getTagName()); rtnValue = getNestedText((Element) node); break; } } return rtnValue; } }