Re: [Htmlparser-user] StackOverflowError when toHtml() is called
Brought to you by:
derrickoswald
|
From: Derrick O. <der...@ro...> - 2007-06-06 23:46:10
|
Hi,
It sounds like a bug.
Please file it with this test code.
Derrick
----- Original Message ----
From: Hanh-Missi Tran <mi...@li...>
To: htm...@li...
Sent: Wednesday, June 6, 2007 11:58:27 AM
Subject: [Htmlparser-user] StackOverflowError when toHtml() is called
Hi
I want to add an attribute to each tag in a html document. I have
written a nodevisitor to do that and it works. However, for some
documents, I get a StackOverflowError when I want to output the html
back. Here is my code.
public class TestHTMLParser
{
public static void main(String args[]) throws Exception
{
Parser p = new Parser("http://lemonde.fr";);
NodeList nliste = p.parse(null);
NodeIterator ni = nliste.elements();
MyNodeVisitor mynv = new MyNodeVisitor();
while (ni.hasMoreNodes())
{
Node n = ni.nextNode();
if (n instanceof Html)
n.accept(mynv);
}
System.out.println(nliste.toHtml());
}
}
public class MyNodeVisitor extends NodeVisitor {
public MyNodeVisitor() {
super();
}
public void visitTag(Tag tag){
tag.setAttribute("onClick", "return false;");
}
}
If I don't use the nodevisitor, I don't get the StackOverflowError.
So is it normal (my html tree has become too deep after the attributes
add) or is there a bug ?
Thanks for help.
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Htmlparser-user mailing list
Htm...@li...
https://lists.sourceforge.net/lists/listinfo/htmlparser-user
|