[jdom-interest] Remove elements

Ladhani, Dilip dladhani at gltg.com
Mon Jun 17 13:49:01 PDT 2002


Hi guys,
 
I am trying to remove some elements from an xml doc based on some logic. Heres a sample of what I am doing.
 
List listSections = dataRs.getChildren("ABC");
Iterator iterSections = listSections.iterator();   
while(iterSections.hasNext()){
elemSection =  (Element) iterSections.next();
if(elemSection.getChildTextTrim("HDG").equalsIgnoreCase("XYX"){
        iterSections.remove();
}
} 
 
After this, when I try to print the xml, the elements which are supposed to be removed are still present!! I also tried using listSections.detach() instead of iterSections.remove(), but that didn't work either.
What am I doing wrong????
 
In general, how do I remove elements??
 
Thanks for your time.



More information about the jdom-interest mailing list