import java.lang.Integer; import java.io.*; import java.util.*; import org.w3c.dom.*; import org.w3c.dom.html.*; import org.openxml.*; import org.openxml.parser.*; class TestParser2 { public static void main (String args[]) throws IOException { //Document aDoc = new Document(); //URL aURL = null; //InputStream s; String initialText = "\n" + "\n" + "Color and font test:\n" + "\n" + "\n" + "\n"; String s = null; try { s = "file:" + System.getProperty("user.dir") + System.getProperty("file.separator") + "Hello.html"; } catch (Exception e) { System.err.println("Couldn't create a URL: " + s); } //File inputFile = new File("Hello.html"); //FileInputStream in = new FileInputStream(inputFile); StringReader aReader = new StringReader(initialText); HTMLParser aParser = new HTMLParser(aReader, s); HTMLDocument aDoc = (HTMLDocument)aParser.parseDocument(); //in.close(); System.out.println("HTMLParser is constructed.\n"); //aDoc.setTitle("Test"); System.out.println("URL: " + aDoc.getURL() + "\n"); System.out.println(aDoc.getDocumentElement().getFirstChild().getNodeName() + "\n"); System.out.println(aDoc.getDocumentElement().getFirstChild().getNodeValue() + "\n"); System.out.println("---Text Only Output---"); list ( aDoc ); } static void list ( Node node ) { while ( node != null ) { if ( node.getNodeName().compareTo("#text") == 0 ) { System.out.print( node.getNodeValue() ); } if ( node.hasChildNodes() ) { list ( node.getFirstChild() ); } node = node.getNextSibling(); } } }