hi,I want the following html: <HTML><BODY><FORM ACTION='from.do'></FORM></BODY></HTML> become <HTML><BODY><TABLE ID='LJW'><FORM ACTION='from.do'></FORM></TABLE></BODY></HTML>
following is my java code:
String HTML_WITH_LINK = "<HTML><BODY><FORM ACTION='from.do'></FORM></BODY></HTML>"; Parser parser = Parser.createParser(HTML_WITH_LINK, null); NodeList list = parser.parse(null); FormTag formTag = (FormTag) list.extractAllNodesThatMatch(new NodeClassFilter(FormTag.class), true).elementAt(0); TableTag table = new TableTag(); table.setAttribute("id", "ljw"); formTag.getParent().setChildren(new NodeList(table)); table.setParent(formTag.getParent()); table.setChildren(new NodeList(formTag)); formTag.setParent(table); String result = list.toHtml(true); System.out.println(result);
but the result print is :
<HTML><BODY><TABLE id=ljw><FORM ACTION='from.do'></FORM></BODY></HTML>
no </TABLE> end tag,how can i do?
thanks
Best rgds
I think a table.setEndTag (new Tag ("/TABLE")); should work.
thanks,but Tag is interface,can not be instanced,and I am confused that the end tag of the table tag is fixed,why need invoke setEndTag everyTime?
Best Rgds
Sorry I should have said TagNode. End tags are only applicable to some tags, that's why they aren't automatically added.
Thanks ,I use: ... TagNode end = new TagNode(); table.setEndTag(end); ... The issue resolved.
But I still think auto added end tag is necessary when user create TableTag clearly.
Log in to post a comment.
hi,I want the following html:
<HTML><BODY><FORM ACTION='from.do'></FORM></BODY></HTML>
become <HTML><BODY><TABLE ID='LJW'><FORM ACTION='from.do'></FORM></TABLE></BODY></HTML>
following is my java code:
String HTML_WITH_LINK =
"<HTML><BODY><FORM ACTION='from.do'></FORM></BODY></HTML>";
Parser parser = Parser.createParser(HTML_WITH_LINK, null);
NodeList list = parser.parse(null);
FormTag formTag = (FormTag) list.extractAllNodesThatMatch(new
NodeClassFilter(FormTag.class), true).elementAt(0);
TableTag table = new TableTag();
table.setAttribute("id", "ljw");
formTag.getParent().setChildren(new NodeList(table));
table.setParent(formTag.getParent());
table.setChildren(new NodeList(formTag));
formTag.setParent(table);
String result = list.toHtml(true);
System.out.println(result);
but the result print is :
<HTML><BODY><TABLE id=ljw><FORM ACTION='from.do'></FORM></BODY></HTML>
no </TABLE> end tag,how can i do?
thanks
Best rgds
I think a table.setEndTag (new Tag ("/TABLE")); should work.
thanks,but Tag is interface,can not be instanced,and I am confused that the end tag of the table tag is fixed,why need invoke setEndTag everyTime?
Best Rgds
Sorry I should have said TagNode.
End tags are only applicable to some tags, that's why they aren't automatically added.
Thanks ,I use:
...
TagNode end = new TagNode();
table.setEndTag(end);
...
The issue resolved.
But I still think auto added end tag is necessary when user create TableTag clearly.
Best Rgds