in reply to Issue with looping through XML::LibXML::Reader

First if you're not already using it, I recommend Use strict and warnings, as your code currently has a few uninitialized variables of questionable origin. Next, that modules seems klunky for this purpose, I'd use XML::Rules (I don't print out the same thing as you, since I don't know where you want to get some of what you want):
use strict; use warnings; use XML::Rules; my $xml = <<XML; <FIXML r="20030618" s="20040109" v="4.4" xr="FIA" xv="1"> <Batch> <MktDataFull RptID="13793742" BizDt="2011-12-23"> <Instrmt Sym="MID" MMY="20120317"/> <Full Typ="5" Px="5.303128"/> <Full Typ="D" Px="884.91"/> </MktDataFull> <MktDataFull RptID="14536119" BizDt="2011-12-23"> <Instrmt Sym="MID" MMY="20120218"/> <Full Typ="5" Px="214.007661"/> <Full Typ="D" Px="884.91"/> </MktDataFull> </Batch> </FIXML> XML my @rules = ( MktDataFull => sub { my $data = $_[1]; for my $full (@{$data->{Full}}) { print join(",", @$data{qw(RptID BizDt Sym MMY)}, @$full{qw(Typ P +x)}), "\n"; } return; }, Instrmt => 'pass', Full => 'as array', ); my $xr = XML::Rules->new(rules => \@rules, stripspaces => 3); $xr->parse($xml);