Parsing HTML into DOM using HTMLEditorKit
I am trying to parse an HTML file using javax.swing.text.html.HTMLEditorKit. My limitations are that I cannot install new libraries like jtidy and I must use a .jsp file, not a servlet. I'm able to get the url and parse it using ParserCallBack, but the new handleText method will not write to the page. Further more I cannot pass anything out of this method to use later because it is void. I want to get some data back from this method or at least do something useful within it. Is that possible?
java.net.URL url =new java.net.URL("http://" + request.getServerName() +"/" + urls.get(i));
java.io.InputStream is = url.openStream();
java.io.InputStreamReader isr =new java.io.InputStreamReader(is);
java.io.BufferedReader br =new java.io.BufferedReader(isr);
javax.swing.text.html.HTMLEditorKit.ParserCallback callback =
new javax.swing.text.html.HTMLEditorKit.ParserCallback (){
publicvoid handleText(char[] data,int pos){
out.println(data);
}
};
new javax.swing.text.html.parser.ParserDelegator().parse(br, callback,false);
Attempting to print from within this method gives this error:
Attempt to use a non-final variable out from a different method. From enclosing blocks, only final local variables are available.
Maybe I need to try and write the output xml file all from inside the parserCallback?

