How to delete the exact element when there are multiple elements with same name?

320 views Asked by At

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

1

There are 1 answers

0
RealSkeptic On BEST ANSWER

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 the removeContent() method that accepts a Content reference (Javadoc).