Java XML Element Child Append appendChildElementBoolean(Element parentNode, String tagName, boolean content)

Here you can find the source of appendChildElementBoolean(Element parentNode, String tagName, boolean content)

Description

append Child Element Boolean

License

Apache License

Declaration

public static Element appendChildElementBoolean(Element parentNode, String tagName, boolean content) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import org.w3c.dom.*;

public class Main {
    public static Element appendChildElementBoolean(Element parentNode, String tagName, boolean content) {
        Element elem = appendChildElement(parentNode, tagName);
        setBooleanContent(elem, content);
        return elem;
    }//from  w  w  w .  j a  va  2  s . c o m

    public static Element appendChildElement(Element parentNode, String nodeName) {
        Document doc = parentNode.getOwnerDocument();
        Element childNode = doc.createElement(nodeName);
        parentNode.appendChild(childNode);
        return childNode;
    }

    public static void setBooleanContent(Element elem, boolean value) {
        setTextContent(elem, value ? "true" : "false");
    }

    public static void setTextContent(Element elem, String content) {
        Document doc = elem.getOwnerDocument();
        if ((content != null) && !content.equals("")) {
            Text textNode = doc.createTextNode(content);
            elem.appendChild(textNode);
        }
    }
}

Related

  1. appendChild(Document document, Node root, String name, String value)
  2. appendChildElement(Document doc, Element parent, Element child)
  3. appendChildElement(Element parent, Element el, String[] order)
  4. appendChildElement(Element parentNode, String nodeName)
  5. appendChildElement(final Element parentElement, final String name, final String value)
  6. appendChildElmt(Element aElmt, String aChildName)
  7. appendNewComment(Element parentElement, String commentText)
  8. appendNewElement(Document document, Element parent, Enum el)
  9. appendNewElement(Document document, Element parent, String element, Object content, String namespace)