code: 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;
  
      }
docs: Removes all the given tags from the document.
  
  @param dom     the document object.
  @param tagName the tag name, examples: script, style, meta
  @return the changed dom.