XOM (XML Object Model) is a tree based java API for processing XML
by taking the best ideas from SAX and DOM. It is simple, fast and easy to use.
This requires the library xom-1.2.7.jar to be in classpath.
The following example shows removing a child element from parent by index.
//Reads and parses the XML
Document doc = builder.build(ins);
//Get student list and
//children of student
// 0 - white space text node [depends on the XML formatting]
// 1 - name node
// 2 - white space text node
// 3 - age node
Elements students = doc.getRootElement().getChildElements(); for (int i = 0 ; i < students.size() ; i ++) {
//Remove fourth child (Zero based index)
System.out.println(students.get(i).removeChild(3));
}