I'm using following code (output below): After parsing and writing - HTML document looses <FORM> tags Can anybody explain why it is happening and how to prevent it.
// The Document class does not yet handle charset's properly. doc.putProperty("IgnoreCharsetDirective", Boolean.TRUE); try {
// Create a reader on the HTML content. Reader rd = new StringReader(html); // reads from a string
// Parse the HTML. kit.read(rd, doc, 0);
// Iterate through the elements // of the HTML document. ElementIterator it = new ElementIterator(doc); javax.swing.text.Element elem; while ((elem = it.next()) != null) { dumpElementAttributes(elem); }
Writer wr = new StringWriter(); kit.write(wr, doc, 0, doc.getLength()); out_html=wr.toString();
System.out.println(out_html);
} catch (Exception e) { e.printStackTrace(); return "There was an error"; } return out_html; }
TEST 1<br> TEST 2<br> TEST 3<br> <a href=http://localhost/test2.html>test2.html</a> <br> <FORM action="member_login.jsp" method=POST> <INPUT TYPE="SUBMIT" value="Go"> </FORM> <p> <FORM NAME="IndexInputForm" onSubmit="IndexInputSubmit(); return false;"> <INPUT TYPE="submit" VALUE="Go"> </FORM>
</body> ................................... ......................... name : html function IndexInputSubmit() { location.href = "http://localhost/test2.html"; re turn true; } TEST 1 TEST 2 TEST 3 test2.html name : head name : content name : body name : p-implied function IndexInputSubmit() { location.href = "http://localhost/test2.h tml"; return true; } TEST 1 TEST 2 TEST 3 test2.html language : javaScript name : script f name : content function IndexInputSubmit() { location.href = "http://localhost/test2.ht ml"; return true; } endtag : true name : script name : content name : br name : content name : br name : content name : br a : href=http://localhost/test2.html name : content name : br model : javax.swing.DefaultButtonModel@7a39ea name : input form : action=member_login.jsp method=post value : Go type : submit name : content name : p model : javax.swing.DefaultButtonModel@7053be name : input form : name=IndexInputForm onsubmit=IndexInputSubmit(); return false; value : Go type : submit name : content name : p name : content ............................................................ <html&g t; <head>
</head> <body> <script language="javaScript"> function IndexInputSubmit() { location.href = "http://localhost/test2.html"; return true; } </script> TEST 1<br>
TEST 2<br>TEST 3<br><a href="http://localhost/test2.html">test2.html</a><br><inp ut value="Go" type="submit">