Re: [Htmlparser-user] How to create a new HTML document using htmlparser
Brought to you by:
derrickoswald
|
From: Derrick O. <Der...@Ro...> - 2006-03-19 13:28:33
|
Vishal,
HTML Parser is not really the right tool for creating content -- it's a
parser.
Building a web page from scratch using the set of node constructors
provided would be fairly tedious, and what's the point... you are just
going to convert it to text anyway.
But, to answer your questions, the end node needs to be set explicitly
with something like:
TagNode end = new new TagNode ();
end.setTagName ("/TABLE");
table_tag.setEndTag (end);
and the children would need to be added separately with something like:
body_tag.setChildren (new NodeList (new TextNode ("hi")));
or
body_tag.getChildren ().add (new TextNode ("hi"));
You can also bootstrap yourself into it by parsing fragments and then
editing the pieces...
parser.setInputHtml ("<body align=valign>hi</body>");
body_tag = parser.parse (null).elementAt (0);
body_tag.setChildren (new NodeList (new TextNode ("hi")));
Derrick
Vishal Monpara wrote:
> Hi All,
>
> I want to process one html file and according to the content
> extracted, I have to build another HTML file from scratch. I tried
> hard to find out how to implement this feature, but I couldnt succeed.
> If you know any online example, please forward the link to me. If you
> have any sample file / sample code / idea of how to build it, please
> please forward it to me. I tried some code like
>
> NodeList ls = new NodeList(new TableTag());
> System.out.println(ls.toHtml());
>
> but this tag renders only "TABLE" and it is not showing any end tag
> like "</table>". I tried TagNode.setText("<body
> align=valign>hi</body>") and if I try "toHtml" function, it shows only
> "<body align=valign>".
>
> Thanks in advance,
>
> Regards,
> Vishal Monpara
>
|