public static Document removeTags ( Document dom , String tagName ) { NodeList list ; try { list = XPathHelper . evaluateXpathExpression ( dom , "//" + tagName . toUpperCase ( ) ) ; while ( list . getLength ( ) > 0 ) { Node sc = list . item ( 0 ) ; if ( sc != null ) { sc . getParentNode ( ) . removeChild ( sc ) ; } list = XPathHelper . evaluateXpathExpression ( dom , "//" + tagName . toUpperCase ( ) ) ; } } catch ( XPathExpressionException e ) { LOGGER . error ( "Error while removing tag " + tagName , e ) ; } return dom ; }
Removes all the given tags from the document .