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 an attribute from a specific element.
//Reads and parses the XML
Document doc = builder.build(ins);
//Get children
Elements numbers = doc.getRootElement().getChildElements();
Attribute evenAttribute = null; for (int i = 0 ; i < numbers.size() ; i ++) {
//Get the attribute by name
evenAttribute = numbers.get(i).getAttribute("even"); if (evenAttribute != null) {
//Remove the attribute
numbers.get(i).removeAttribute(evenAttribute);
}
}