public static void insertAfter(Node newNode,Node refNode) throws DOMException {
  Node parent=refNode.getParentNode();
  Node next=refNode.getNextSibling();
  if (next == null) {
    parent.appendChild(newNode);
  }
 else {
    parent.insertBefore(newNode,next);
  }
}

public static void insertAfter ( Node newNode , Node refNode ) throws DOMException { Node parent = refNode . getParentNode ( ) ; Node next = refNode . getNextSibling ( ) ; if ( next == null ) { parent . appendChild ( newNode ) ; } else { parent . insertBefore ( newNode , next ) ; } }
analogous to the node . insertbefore ( ) method , insert a newnode after a refnode .
