Guys:
I have a problem to remove an element from a XML file with JDOM 2.5. The problem is: under the same parent element "ApproachDat", there are multiple elements with same name as "Notes", and I only want to delete some of them based on a given criteria. I have find qualified elements that I want to delete, but I notice JDOM 2.5 only provides removeChild, which removes the first found child with given name; or removeChildren, which removes all of children elements with given name. Is there anyway to remove the exact child element that qualifies a condition?
Thanks a lot!
Sam
If you have a reference to the actual element you want to remove, remember that it is polymorphically a
Content
object. So you can use theremoveContent()
method that accepts aContent
reference (Javadoc).