Java tutorial
//package com.java2s; import org.w3c.dom.Node; public class Main { /** * Replace the old node with the new node. * * @param parent * the node parent * @param oldNode * the old node * @param newNode * the new node */ public static void replaceNode(Node parent, Node oldNode, Node newNode) { parent.replaceChild(newNode, oldNode); } }