title: Extract and Clean HTML Fragment using HTML Parser (org.htmlparser)
body: <p>I'm looking for an efficient approach to extracting a fragment of HTML from a web page and performing some specific operations on that HTML fragment.</p>
  
  <p>The operations required are:</p>
  
  <ol>
  <li>Remove all tags that have a class of "hidden" </li>
  <li>Remove all script tags</li>
  <li>Remove all style tags</li>
  <li>Remove all event attributes (on*="*")</li>
  <li>Remove all style attributes</li>
  </ol>
  
  <p>I've been using <a href="http://htmlparser.sourceforge.net/" rel="noreferrer">HTML Parser</a> (org.htmlparser) for this task and have been able to meet all of the requirements, however, I don't feel that I have an elegant solution.  Currently, I am parsing the web page with a <a href="http://htmlparser.sourceforge.net/javadoc/index.html" rel="noreferrer">CssSelectorNodeFilter</a> (to get the fragment) and then re-parsing that fragment with a <a href="http://htmlparser.sourceforge.net/javadoc/index.html" rel="noreferrer">NodeVisitor</a> in order to carry out the cleaning operations.</p>
  
  <p>Could anybody suggest how they would tackle this problem?  I would prefer to only parse the document once and perform all operations during that one parse.</p>
  
  <p>Thanks in advance!</p>