in reply to Re: How to parse HTML5?
in thread How to parse HTML5?

could you give me any short example with "HTML::TreeBuilder"

But i also need error log with "line number" and "column number"

Then after end user go that line number and then correct it

Is it possible?

Thanks
Nikhil Ranjan

Replies are listed 'Best First'.
Re^3: How to parse HTML5?
by Corion (Patriarch) on Mar 08, 2016 at 12:17 UTC

    What kind of errors do you want? If you're after finding malformed HTML, HTML::Tidy is better, because HTML::TreeBuilder will automatically correct much of the HTML.

      No I don't want auto correction

      I want i do it manual

      suppose <p> is missing, then it gives me only error log not correct it

      Thanks
      Nikhil Ranjan

        If you just want errors then maybe use tidy directly

        #!perl use strict; my $text = join '|',qw(DOCTYPE html meta header); my $re = qr/$text/; my $filename = 'd:/perl/test.xhtml'; my $tidy = '..../tidy/bin/tidy.exe'; # change to your path my @msg = qx"$tidy -eq -utf8 $filename 2>&1"; for (@msg){ print $_ unless /$re/; } # line 10 column 1 - Warning: missing </section>
        poj