Java XML Node Insert insertAfter(Node refNode, Node newNode)

Here you can find the source of insertAfter(Node refNode, Node newNode)

Description

Insert a node directly after a reference node.

License

BSD License

Parameter

Parameter Description
refNode The reference node. New node will be inserted after this one.
newNode The new node to be inserted.

Declaration

public static void insertAfter(Node refNode, Node newNode) 

Method Source Code

//package com.java2s;
/*// w w w . j  av  a 2  s  .com
 * This file is released under terms of BSD license
 * See LICENSE file for more information
 */

import org.w3c.dom.Node;

public class Main {
    /**
     * Insert a node directly after a reference node.
     *
     * @param refNode The reference node. New node will be inserted after this
     *                one.
     * @param newNode The new node to be inserted.
     */
    public static void insertAfter(Node refNode, Node newNode) {
        refNode.getParentNode().insertBefore(newNode,
                refNode.getNextSibling());
    }
}

Related

  1. insertAfter(Node newNode, Node refNode)
  2. insertBefore(Node currentNode, Node insertNode)