Hi everybody.
Well. I am using the Swing HTML parser to parse some HTML files and store the
text (among other things) into memory. To do so I use a ParserCallback class
that extends HTMLEdotorkit.ParserCallback, and handle events such as
handleStart/EndTag(), handleText(), handleError()...
It worked very well until I realized that some <STYLE> tag (in the middle of my
page) don't trigger a "handleStartTag()" event, but a "handleError()" event. So
the code between <STYLE> and </STYLE> is computed as text, and as the parser
didn't detect the <style> as a tag, I can't know if the text belongs to such a tag.
Why this parser doesn't trigger a "handleStartTag()" when parsing a <style> tag
? Is anybody aware of that ?
Thank you in advance.
Xav
Thomas Weidenfeller - 26 Jul 2004 12:34 GMT
> Why this parser doesn't trigger a "handleStartTag()" when parsing a
> <style> tag ? Is anybody aware of that ?
The Swing HTML parser is rather limited. In fact, the parser is part of
the remains of Sun's old HotJava web browser. I don't belief it has been
updated since the days of HotJava.
If you need it for "real" HTML, and not just specifically for the parser
tailored HTML, you will get several such surprises. Consider using
another parser.
/Thomas
JavaJug - 26 Jul 2004 14:06 GMT
> If you need it for "real" HTML, and not just specifically for the parser
> tailored HTML, you will get several such surprises. Consider using
> another parser.
Yes, I was afraid os such an answear. I think i'll end up by switching to
another one, when I'll have some time (got a lot of code using this one...)
Thanks folks !
Anony! - 26 Jul 2004 13:00 GMT
> Hi everybody.
> Well. I am using the Swing HTML parser to parse some HTML files and store the
[quoted text clipped - 9 lines]
> Thank you in advance.
> Xav
style tag is supported, so don;t know why u getting this error.
check java sun tutorial on the html parser
AaA