Swing HTMLParser problem

J

JavaJug

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
 
T

Thomas Weidenfeller

JavaJug said:
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
 
A

Anony!

JavaJug said:
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
? Is anybody aware of that ?
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
 
J

JavaJug

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 !
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top