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 name.
//Reads and parses the XML
Document doc = builder.build(ins);
//Get student list
Elements students = doc.getRootElement().getChildElements();
Element ageChild = null;
for (int i = 0 ; i < students.size() ; i ++) {
//Get age element
ageChild = students.get(i).getFirstChildElement("age"); if (ageChild != null) {
//Remove age element
System.out.println(students.get(i).removeChild(ageChild));
}
}