In the below sample XML, how to remove Entire B Node if E=13 using java parser.
11
Here is the code of removing node B using XPath with predicate. It is based on VTD-XML, which uniquely implements incremental update.
import com.ximpleware.*;
import java.io.*;
public class removeNode {
public static void main(String s[]) throws VTDException, IOException{
VTDGen vg = new VTDGen();
if (!vg.parseFile("input.xml", false));
VTDNav vn = vg.getNav();
AutoPilot ap = new AutoPilot(vn);
XMLModifier xm = new XMLModifier(vn);
ap.selectXPath("/xml/A/B[C/E='13']");
while (ap.evalXPath()!=-1){
xm.remove();
}
xm.output("output.xml");
}
}