Java XML Child Element Add addChildElement(Element root, Element element, String name)

Here you can find the source of addChildElement(Element root, Element element, String name)

Description

add Child Element

License

Open Source License

Declaration

public static Element addChildElement(Element root, Element element, String name) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import org.w3c.dom.Element;

public class Main {
    public static Element addChildElement(Element root, Element element, String name) {
        String safeName = name.replaceAll("\\$", "::");
        Element child = getNewElement(root, safeName);
        element.appendChild(child);/*  ww  w .  jav  a2 s  . c  om*/
        return child;
    }

    public static Element getNewElement(Element element, String name) {
        String safeName = name.replaceAll("\\$", "::");
        return element.getOwnerDocument().createElement(safeName);
    }
}

Related

  1. addChildElement(Element element, String name, String text)
  2. addChildElement(Element element, String name, String text)
  3. addChildElement(Element element, String name, String text)
  4. addChildElement(Element parentElement, String elementName)
  5. addChildElement(Element parentElement, String elementName)
  6. addChildElement(Node element, String name, String[][] attributes)
  7. addChildElement(Node parent, String elementName, String textContent)
  8. addChildElement(Node parent, String tag, String value)
  9. addChildElements(Node n, List elements)