Java XML Duration Add appendElement(Element parent, String tagName, String value)

Here you can find the source of appendElement(Element parent, String tagName, String value)

Description

append Element

License

Apache License

Declaration

public static Element appendElement(Element parent, String tagName, String value) 

Method Source Code

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

import org.w3c.dom.Element;
import org.w3c.dom.Node;

public class Main {
    public static Element appendElement(Element parent, String tagName) {
        Element child = parent.getOwnerDocument().createElement(tagName);
        parent.appendChild(child);//w w w  .ja v  a  2s .  c o m
        return child;
    }

    public static Element appendElement(Element parent, String tagName, String value) {
        Element child = appendElement(parent, tagName);
        child.appendChild(child.getOwnerDocument().createTextNode(value));
        return child;
    }

    public static void appendElement(Element parent, Element child) {
        Node tmp = parent.getOwnerDocument().importNode(child, true);
        parent.appendChild(tmp);
    }
}

Related

  1. addNode(Element parent, String elementName, String namespaceURI)
  2. addNode(Node parentNode, String name)
  3. addText(Node parent, String value)
  4. addTextElement(Node parent, String name, String value)
  5. appendElement(Element parent, String tagName)
  6. appendElement(Element parent, String type)
  7. appendElement(Node parent, String name)
  8. appendElement(Node parent, String name)
  9. appendElement(Node parent, String tagName)