public static void deleteTagContents(Element parentElement,String name){
  NodeList children=parentElement.getElementsByTagName(name);
  for (int i=children.getLength() - 1; i >= 0; i--) {
    Element child=(Element)children.item(i);
    parentElement.removeChild(child);
  }
}

public static void deleteTagContents ( Element parentElement , String name ) { NodeList children = parentElement . getElementsByTagName ( name ) ; for ( int i = children . getLength ( ) - 1 ; i >= 0 ; i -- ) { Element child = ( Element ) children . item ( i ) ; parentElement . removeChild ( child ) ; } }
this method removes all child elements with the given name of the given element .
