syntax error at line 1, column 0, byte 0 at /usr/lib/perl5/vendor_perl/5.6.1/i386-linux/XML/Parser.pm line 185
####
#!/usr/bin/perl
use strict;
use warnings;
use XML::Parser;
use LWP::Simple;
our %XLINK;
my $parser = new XML::Parser( Handlers => {
Start => \&handle_start,
End => \&handle_end
}
);
$parser->parse('test.xml');
sub handle_start {
my $expat = shift;
my $element = shift;
my %attrs = @_;
foreach my $attr (keys %attrs) {
my ($ns,$elm) = split /\:/, $attr, 2;
next unless $ns =~ /xmlns/i;
if($attrs{$attr} eq 'http://www.w3.org/1999/xlink') {
$XLINK{label} = $elm;
$XLINK{element} = $element;
last;
}
}
my %link = ();
if($XLINK{label}) {
foreach my $attr (grep /$XLINK{label}/, keys %attrs) {
my ($ns,$a) = split /\:/,$attr,2;
next unless $ns eq $XLINK{label};
$link{lc $a} = $attrs{$a};
}
if(exists $link{href} && $link{type} eq 'simple') {
print retrieve($link{href});
}
}
}
sub handle_end {
my $expat = shift;
my $element = shift;
%XLINK = () if $element eq $XLINK{element};
}
sub retrieve {
my $url = shift;
return get($url);
}
####
Testing this thing
funky
monkey