#!/usr/bin/perl --
use strict;
use warnings;
use XML::Twig;
my $xml = q{
5 Spoke Wheel
Reconditioned OEM
123.45
http://www.foo.com
http://www.foo.com/foo.jpg
};
$xml = join '', '',$xml, $xml, $xml, '';
XML::Twig->new(
twig_roots => {
'/root/product' => sub {
print join "\n",
$_->path,
$_->first_child('name' )->text,
$_->first_child('price' )->text,
$_->first_child('buyurl' )->text,
"\n";
},
},
)->parse( $xml );