in reply to Re^2: Parsing HTML/XML with Regular Expressions
in thread Parsing HTML/XML with Regular Expressions
#!/usr/bin/perl use warnings; use strict; use feature qw{ say }; use XML::LibXML; my $dom = 'XML::LibXML'->load_xml(location => '1.xml', load_ext_dtd => + 0); my $xpc = 'XML::LibXML::XPathContext'->new; $xpc->registerNs(xh => 'http://www.w3.org/1999/xhtml'); for my $div ($xpc->findnodes('//xh:div[@class="data"]', $dom)) { print $div->{id}, "\n" }
Interestingly, at the same time the following shows the classes of all the divs as data:
for my $div ($xpc->findnodes('//xh:div', $dom)) { print join ' ', @{ $div }{qw{ id class }}, "\n" }
Bugreport anyone?
($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^4: Parsing HTML/XML with Regular Expressions
by haukex (Archbishop) on Oct 18, 2017 at 22:05 UTC | |
by choroba (Cardinal) on Oct 18, 2017 at 22:13 UTC | |
by haukex (Archbishop) on Oct 18, 2017 at 22:54 UTC | |
by choroba (Cardinal) on Oct 19, 2017 at 10:02 UTC |