Java XML Attribute Append appendAttributeNode(String namespace, Element parent, String name, String value)

Here you can find the source of appendAttributeNode(String namespace, Element parent, String name, String value)

Description

append Attribute Node

License

CDDL license

Parameter

Parameter Description
namespace String
parent Element
name String
value String

Declaration

public static void appendAttributeNode(String namespace, Element parent, String name, String value) 

Method Source Code

//package com.java2s;
/*/*from   ww w .  j av a2 s  .c o  m*/
Copyright (c) 2013 eBay, Inc.
This program is licensed under the terms of the eBay Common Development and
Distribution License (CDDL) Version 1.0 (the "License") and any subsequent  version 
thereof released by eBay.  The then-current version of the License can be found 
at http://www.opensource.org/licenses/cddl1.php and in the eBaySDKLicense file that 
is under the eBay SDK ../docs directory.
*/

import org.w3c.dom.Element;

public class Main {
    /**
     *
     * @param parent Element
     * @param name String
     * @param value String
     */
    public static void appendAttributeNode(Element parent, String name, String value) {
        parent.setAttribute(name, value);
    }

    /**
     *
     * @param namespace String
     * @param parent Element
     * @param name String
     * @param value String
     */
    public static void appendAttributeNode(String namespace, Element parent, String name, String value) {
        parent.setAttributeNS(namespace, name, value);
    }

    /**
     *
     * @param parent Element
     * @param name String
     * @param value int
     */
    public static void appendAttributeNode(Element parent, String name, int value) {
        parent.setAttribute(name, new Integer(value).toString());
    }

    /**
     *
     * @param namespace String
     * @param parent Element
     * @param name String
     * @param value int
     */
    public static void appendAttributeNode(String namespace, Element parent, String name, int value) {
        parent.setAttributeNS(namespace, name, new Integer(value).toString());
    }
}

Related

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