5 Apr 2012 evilrobots   » (Observer)

# basic skeleton for Perl XML parser; thomas@thurman.org.uk
use strict;
use warnings;
use XML::Parser;

my $capture;

my $p = new XML::Parser(
Handlers => {
Start => sub {
my ($parser, $tag, %attrs) = @_;
},
End => sub {
my ($parser, $tag) = @_;
},
Char => sub {
my ($parser, $text) = @_;

$capture .= $text if defined $capture;
},
});
$p->parsefile('foo.xml');

Latest blog entries     Older blog entries

X
Share this page