public static void removeNodesByTagName ( Element doc , String tagname ) { NodeList nodes = doc . getElementsByTagName ( tagname ) ; for ( int i = 0 ; i < nodes . getLength ( ) ; i ++ ) { Node n = nodes . item ( i ) ; doc . removeChild ( n ) ; } }
Removes elements by a specified tag name from the xml Element passed in .