Java XML Attribute Append appendBooleanAttribute(Element thisElement, String attrName, boolean value)

Here you can find the source of appendBooleanAttribute(Element thisElement, String attrName, boolean value)

Description

append Boolean Attribute

License

Open Source License

Declaration

public static void appendBooleanAttribute(Element thisElement, String attrName, boolean value) 

Method Source Code

//package com.java2s;
/**//from   ww w .j a va2s  .  c  o 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.Attr;

import org.w3c.dom.Element;

public class Main {
    public static void appendBooleanAttribute(Element thisElement, String attrName, boolean value) {
        appendStringAttribute(thisElement, attrName, String.valueOf(value));
    }

    public static void appendStringAttribute(Element thisElem, String attrName, String attrValue) {
        Attr attr = thisElem.getOwnerDocument().createAttribute(attrName);

        attr.setTextContent(attrValue);
        thisElem.setAttributeNode(attr);

    }
}

Related

  1. appendAllAttributes(Node node, StringBuffer xpath)
  2. appendAttribute(Node node, String name, String value)
  3. appendAttributeIfNotNull(Element parentElement, String attributeName, Object attributeValue)
  4. appendAttributeNode(String namespace, Element parent, String name, String value)
  5. appendAttributes(Node node, StringBuffer sb)
  6. appendBooleanElement(Element parentElement, String nodeName, boolean value)