in reply to "combined" HTML *and* CSS parser?

Sure it's possible. You have to keep some state to know which things apply to which tags (DIV, SPAN, and so on defining a scope), then looking in your CSS data structure to get the right elements. You just have to apply things like the CSS spec says you should.

I'm not sure HTML::Tree will be low-level enough for you to do that, and you can always right your own parser as a sub-class of HTML::Parser if something else doesn't do what you want.

--
brian d foy <brian@stonehenge.com>

Replies are listed 'Best First'.
Re^2: "combined" HTML *and* CSS parser?
by telcontar (Beadle) on Apr 13, 2005 at 12:17 UTC
    Hi,

    yes, of course it's possible ;-) (and there's More Than One Way To Do It ...) But implementing all of CSS Level 2 (or a large subset of it) to combine it with a HTML parser is, well, a lot of work. I thought maybe someone had already done that, or there was some module to do it. Not that I don't want to give it a try; rather, I'd not waste time doing something someone else has already done.

    I'm also rather new at Perl, so it would probably take rather long. Since I have a specific set of tasks that I would need to check, maybe I can use HTML::Tree and the CSS distribution after all. Although I must say that I find the documentation of the CSS distribution lacking, and wonder why there are no methods to navigate the object tree- probably will just have to access the properties directly and have a look at the code.

    Thanks for the reply!


    John