Swing HTMLParser problem

Discussion in 'Java' started by JavaJug, Jul 26, 2004.

  1. JavaJug

    JavaJug Guest

    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
    JavaJug, Jul 26, 2004
    #1
    1. Advertising

  2. JavaJug wrote:
    > 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
    Thomas Weidenfeller, Jul 26, 2004
    #2
    1. Advertising

  3. JavaJug

    Anony! Guest

    "JavaJug" <> wrote in message
    news:ce2njs$sr6$...
    > 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


    style tag is supported, so don;t know why u getting this error.

    check java sun tutorial on the html parser

    AaA
    Anony!, Jul 26, 2004
    #3
  4. JavaJug

    JavaJug Guest

    > 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 !
    JavaJug, Jul 26, 2004
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. mike
    Replies:
    0
    Views:
    882
  2. Big Daddy

    Java 1.2 Swing vs. Java 1.5 Swing

    Big Daddy, Apr 15, 2005, in forum: Java
    Replies:
    2
    Views:
    499
    Pete Barrett
    Apr 16, 2005
  3. mkrause
    Replies:
    0
    Views:
    670
    mkrause
    May 6, 2005
  4. lizard
    Replies:
    0
    Views:
    1,764
    lizard
    Jan 30, 2006
  5. Valkyrie

    HTMLParser problem

    Valkyrie, Nov 16, 2004, in forum: Python
    Replies:
    4
    Views:
    710
    Valkyrie
    Nov 17, 2004
Loading...

Share This Page