RatArsed has asked for the wisdom of the Perl Monks concerning the following question:

I seem to spend half of my life parsing SGML documents, and it occured to me that I hadn't come accross a perl DOM parser.

Now, am I being inept, or is this going to be my chance to take over the world, and develop one? *mwhahahaha*. Ahem.

I quite fancy being able to do something like:

$document->getElementById("wibble")->innerHTML = "Perl is great";
And of course, then throwing the output at CGI.pm or disk or whatever.

--
RatArsed

Replies are listed 'Best First'.
Re: DOM Parsers
by MZSanford (Curate) on Jul 26, 2001 at 14:37 UTC
    i know little and/or nothing about DOM, but found the following references. an article and the module XML::DOM. Not sure these are terribly good implimentations or interfaces ... so a write of a DOM::* specific set of modules might be a good idea. Just thought i would add what i did find.
    Thus spake the Master Programmer:
    "When you have learned to snatch the error code from the trap frame, it will be time for you to leave."
    -- The Tao of Programming
Re: DOM Parsers
by jodrell (Acolyte) on Jul 26, 2001 at 14:52 UTC
    DOM will only work on well-formed XML, so you'd either have to use XHTML, or find a way to convert the standard grotty HTML most people (not me :-P) write to XHTML. That would be hairy indeed.
      Well, I've got the hair :o)

      If you wrote a really manky parser, I expect you could handle really manky code -- DOM was originally developed for (grotty) HTML, although I can see that XHTML would be easier to work with, as someone quoted the other day, "XML is for people who couldn't parse their way out of a paper bag"...

      XML::DOM looks to be halfway there, it would just need the methods added...

      Of course, if there was a W3 DOM Perl parser, the code required to then get it to render HTML would be virtually trivial.

      --
      RatArsed