Try using the HtmlEditorKit class. It supports parsing HTML content that can be read directly from String (e.g. via StringReader ). There seems to be an article on how to do this.
Edit: To give an example, basically I think it could be done as follows (aftrer, code executed, htmlDoc should contain the loaded document ...):
Reader stringReader = new StringReader(string); HTMLEditorKit htmlKit = new HTMLEditorKit(); HTMLDocument htmlDoc = (HTMLDocument) htmlKit.createDefaultDocument(); HTMLEditorKit.Parser parser = new ParserDelegator(); parser.parse(stringReader, htmlDoc.getReader(0), true);
source share