in reply to Re^2: XML::Twig parsing poorly structured content
in thread XML::Twig parsing poorly structured content
It's called XPath. It's used and supported in a wider range of tools/languages/libraries than just XSL. This particular expression means "a div element whose class attribute has the value "event".
> want to parse
Then you can't use handlers, as you need access to more than just a subtree. The following shows how to do it. Using XML::LibXML would simplify the code in such a case, in my opinion.
#!/usr/bin/perl use warnings; use strict; use feature qw{ say }; use XML::Twig; my $twig = 'XML::Twig'->new; $twig->parsefile(shift); my $root = $twig->root; for my $header($root->descendants('h3')) { my $date = $header->text; my @events = $header->next_siblings(sub { my ($elt) = @_; 'div' eq $elt->name && $elt->prev_sibling('h3') == $header }); say join "\t", $date, map $_->text, $_->children for @events; }
($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,
|
|---|