Here you can find the source of appendBooleanElement(Element parentElement, String nodeName, boolean value)
public static void appendBooleanElement(Element parentElement, String nodeName, boolean value)
//package com.java2s; /**//from w w w. j av a 2 s .co m * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation. * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * Copyright 2011 GrossCommerce */ import org.w3c.dom.Element; import org.w3c.dom.NodeList; public class Main { public static void appendBooleanElement(Element parentElement, String nodeName, boolean value) { appendStringElement(parentElement, nodeName, String.valueOf(value)); } public static void appendStringElement(Element parentElement, String nodeName, String nodeValue) { // check for exists Element elem = selectSingleElement(parentElement, nodeName); if (elem == null) { elem = parentElement.getOwnerDocument().createElement(nodeName); parentElement.appendChild(elem); } elem.setTextContent(nodeValue); } public static Element selectSingleElement(Element parent, String elementName) { NodeList list = parent.getElementsByTagName(elementName); if (list.getLength() > 0) { return (Element) list.item(0); } return null; } }