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

Re^5: How to grab a portion of file with regex

by kielstirling (Scribe)
on Mar 15, 2013 at 04:22 UTC ( #1023614=note: print w/ replies, xml ) Need Help??


in reply to Re^4: How to grab a portion of file with regex
in thread How to grab a portion of file with regex


You make some valid points. The example in the question didn't seem to need the content of the div.
I do agree that working with the DOM is a much better way to parse HTML.


Comment on Re^5: How to grab a portion of file with regex
Re^6: How to grab a portion of file with regex
by Anonymous Monk on Mar 15, 2013 at 06:39 UTC

    You make some valid points. The example in the question didn't seem to need to content of the div. I do agree that working with the DOM is a much better way to parse HTML. <

    :)

    #!/usr/bin/perl -- use strict; use warnings; use XML::LibXML; my $dom = XML::LibXML->new( qw/ recover 2 / )->load_html( location => q{junk.html} ); for ( $dom->findnodes(q{ //div[ contains( @class, 'lastUnit' ) ] }) ){ print "\n", $_->nodePath, "\n\n$_\n"; } __END__

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (6)
As of 2015-07-07 06:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (87 votes), past polls