http://www.perlmonks.org?node_id=1004216


in reply to XML Newbie

Here's an example w/XML::Rules. Note that getting at the underlying expat parser is undocumented, but I'm sure Jenda would be willing to add something as part of the official API :-)
use strict; use warnings; use XML::Rules; my @rules = ( gibsonca => undef, _default => sub { no warnings 'uninitialized'; return if $_[1]->{_content} =~ /\S/; my $p = $_[4]{parser}; print $p->current_line(),"\n"; return; }, ); my $xr = XML::Rules->new(rules => \@rules); $xr->parse(<<XML); <gibsonca> <abc>fds </abc> <!-- ok --> <ddd></ddd> <!-- not ok --> <eee> </eee> <!-- not ok --> </gibsonca> XML