Chady,

I'm with ichimunki on this one, use HTML::TokeParser. Here's a basic working snippet of code based on a parser I'm working on. This may be of help to you:
#!/usr/local/bin/perl -w ########################################################### # includes ################################################ ########################################################### use strict; use HTML::TokeParser; ################# ### Variables ### ################# my $file_in = 'test.html'; ################## ### Parse HTML ### ################## my $p = HTML::TokeParser->new($file_in) || die "Can't open: $!"; ## while (my $token = $p->get_token) { my $token_type = @$token[0]; start(@$token[1], @$token[4]) if ($token_type =~ /S/i); # Start Ta +g end(@$token[1], @$token[2]) if ($token_type =~ /E/i); # End Tag text(@$token[1]) if ($token_type =~ /T/i); # Text comment(@$token[1]) if($token_type =~ /C/i); # Comment declaration(@$token[1]) if ($token_type =~ /D/i); # Declaration } ########################################################### # SUB's ################################################### ########################################################### ############# ### DTD's ### ############# sub declaration { my ($declaration) = @_; print "DEC: $declaration\n"; } ################ ### Comments ### ################ sub comment { my ($comment) = @_; print "CMT: $comment\n"; } ##################### ### Text Entities ### ##################### sub text { my ($text) = @_; return if ($text =~ /^(\s+)$/); #skip blank lines $text =~ s/\s+/ /g; #kill off big chunks of whitespace $text =~ s/\n//g; #keep text split across lines together print "TEXT: $text\n"; } ################## ### Start Tags ### ################## sub start { my ($tag, $origtext) = @_; chomp $origtext; print "ST: $tag = $origtext\n"; } ################ ### End Tags ### ################ sub end { my ($tag, $origtext) = @_; chomp $origtext; print "ET: $tag = $origtext\n"; }
You'll need to add whatever logic to grab what tags you need either in the parsing while loop or with one of the sub-routines.

-THRAK
www.polarlava.com

In reply to Re: Parse... then what? (HTML Parsing problems) by THRAK
in thread Parse... then what? (HTML Parsing problems) by Chady

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.