How can I remove the exact element when there are multiple elements with the same name?

Guys:

I have a problem removing an element from an XML file using JDOM 2.5. The problem is that under the same parent "ApproachDat" there are several items with the same name as "Notes" and I only want to remove some of them based on the criteria I specified. I found qualified elements that I want to remove, but I notice that JDOM 2.5 only provides removeChild, which removes the first found child with the given name; or removeChildren, which removes all children with the given name. Is there a way to remove the exact child that qualifies the condition?

Thank you so much!

Sam

+3


source to share


1 answer


If you have a link to the actual element you want to remove, remember that it is a polymorphic object Content

. So you can use a method removeContent()

that takes a link Content

( Javadoc ).



+1


source







All Articles