Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^2: Parsing HTML/XML with Regular Expressions (XML::LibXML; updated!)

by haukex (Archbishop)
on Oct 16, 2017 at 15:12 UTC ( [id://1201454]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    use warnings;
    use strict;
    ...
    $_->[1] =~ s/\W+//g for @ids2text;
    
    print join ", ", map sprintf("%s=%s", @$_), @ids2text;
    
  2. or download this
    my @ids2text = map { [ $_->getAttribute('id'), $_->textContent ] }
        $doc->findnodes(q{//div[@class='data']});
    
  3. or download this
    my $xpc = XML::LibXML::XPathContext->new($doc);
    $xpc->registerNs('html', 'http://www.w3.org/1999/xhtml');
    my @ids2text = map { [ $_->getAttribute('id'), $_->textContent ] }
        $xpc->findnodes(q{//html:div[@class='data']});
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (3)
As of 2024-04-25 17:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found