Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: HTML::TokeParser - extract values between tags

by Anonymous Monk
on Feb 17, 2014 at 12:06 UTC ( #1075163=note: print w/replies, xml ) Need Help??


in reply to HTML::TokeParser - extract values between tags

you're using interpolating heredocs :) double-quoted here docs :) strict vars or warnings would have warned you
#!/usr/bin/perl -- use strict; use warnings; use XML::LibXML 1.70; ## for load_html/load_xml/location use Data::Dump qw/ dd /; my %shabs; my $dom = XML::LibXML->new( qw/ recover 2 / )->load_html( string => $c +ontent ); for my $h5 ( $dom->findnodes( q{ //h5 } ) ){ print $h5->nodePath, "\n"; my $key = $h5->textContent; my $next = $h5->nextSibling; while( $next ){ print $next->nodePath, "\n"; $shabs{$key} .= $next->textContent; $next = $next->nextSibling; last if eval { $next->tagName eq 'h5' } ; } print "\n"; } dd( \%shabs );

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1075163]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (None)
    As of 2021-10-18 00:11 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      My first memorable Perl project was:







      Results (72 votes). Check out past polls.

      Notices?