Java Utililty Methods XML Child Insert

List of utility methods to do XML Child Insert

Description

The list of methods to do XML Child Insert are organized into topic(s).

Method

voidinsertAfter(Node newChild, Node refChild)
__UNDOCUMENTED__
if (refChild == null) {
    throw new DOMException(DOMException.NOT_FOUND_ERR, "refChild == null");
Node nextSibling = refChild.getNextSibling();
if (nextSibling == null) {
    refChild.getParentNode().appendChild(newChild);
} else {
    refChild.getParentNode().insertBefore(newChild, nextSibling);
...
NodeinsertAfter(Node parent, Node newChild, Node refChild)
Inserts the node newChild after the existing child node refChild.
if (refChild != null) {
    Node next = refChild.getNextSibling();
    return parent.insertBefore(newChild, next);
return parent.insertBefore(newChild, refChild);
voidprependChild(Element parent, Element child)
adds a child at the first place
Node first = parent.getFirstChild();
if (first == null)
    parent.appendChild(child);
else {
    parent.insertBefore(child, first);
ElementprependChildElement(Element parent, Element child)
prepend a child element

Node firstChild = parent.getFirstChild();
if (firstChild == null) {
    return (Element) parent.appendChild(child);
} else {
    return (Element) parent.insertBefore(child, firstChild);
ElementprependChildElement(Element parent, Element child)
prepend a child element

Node firstChild = parent.getFirstChild();
if (firstChild == null) {
    return (Element) parent.appendChild(child);
} else {
    return (Element) parent.insertBefore(child, firstChild);