Java tutorial
//package com.java2s; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.NodeList; public class Main { public static boolean getTagValueAsBoolean(Document document, String tagName) { boolean tagValue = false; String tempVal = getTagValueAsString(document, tagName); tagValue = Boolean.parseBoolean(tempVal); return tagValue; } /** * * @param document * @param tagName * @return */ public static String getTagValueAsString(Document document, String tagName) { if (document == null || tagName == null || tagName.length() == 0) return null; String tagValue = null; NodeList nlist = null; Element element = null; Element root = document.getDocumentElement(); nlist = root.getElementsByTagName(tagName); element = (Element) nlist.item(0); if (element.hasChildNodes()) { tagValue = element.getFirstChild().getNodeValue(); } return tagValue; } }