From: SourceForge.net <no...@so...> - 2010-04-21 11:03:50
|
The following forum message was posted by Anonymous at http://sourceforge.net/projects/jtidy/forums/forum/41437/topic/3683463: Right, apparently I messed up the BBCode. This is the Java code: [code]// Load test.html. String file = \"test.html\"; InputStream in = new FileInputStream(file); OutputStream out = null; // Parse test.html into a DOM tree. Tidy tidy = new Tidy(); Document doc = tidy.parseDOM(in, out); // Print <body>\'s text content. org.w3c.dom.Node body = doc.getElementsByTagName(\"body\").item(0); Element bodyElement = (Element) body; String bodyTextContent = bodyElement.getTextContent(); System.out.print(\"<body> TextContent:\\n\" + bodyTextContent);[/code] |