Java XML Child Element Create addElement(Document doc, Node parent, String element)

Here you can find the source of addElement(Document doc, Node parent, String element)

Description

add Element

License

Open Source License

Declaration

public static Element addElement(Document doc, Node parent, String element) 

Method Source Code


//package com.java2s;
import java.util.*;

import org.w3c.dom.*;

public class Main {
    public static Element addElement(Document doc, Node parent, String element) {
        return addElement(doc, parent, element, null);
    }/*from w  w  w . j ava2s. c  o  m*/

    public static Element addElement(Document doc, Node parent, String element, Object textValue) {
        Element elem = doc.createElement(element);
        if (Objects.nonNull(textValue)) {
            elem.setTextContent(String.valueOf(textValue));
        }
        parent.appendChild(elem);

        return elem;
    }
}

Related

  1. addChildEpcList(final Document document, final Element root, final String childEPCs)
  2. addChildNode(Document doc, Node parentNode, String childName, String childValue)
  3. addChildText(Document doc, Element parent, String textValue)
  4. addElement(Document doc, Element parent, String nodeName)
  5. addElement(Document doc, Element rootElement, String elementName, String typeIn, String isArrayIn, String partitionerIn)
  6. addElement(Document doc, String name, Element parent)
  7. addElement(Document document, Element father, String name, String attOneName, String attOneValue, String attTwoName, String attTwoValue)
  8. addElement(Document document, Element parentElement, String elementName, String elementValue)
  9. addElement(final Document doc, final Node parent, final String name)