in reply to TWIGging XML to CSV: what's wrong with my syntax?

And yet another way, using XML::Rules:
use warnings; use strict; use XML::Rules; my @attribs = qw( townname allianceticker playername townname mapy mapx ); my @rules = ( town => sub { my $town = $_[1]; return if $town->{mapx} <= 500; print join(",", @$town{@attribs}), "\n"; return; }, 'player,towndata,location,playeralliance' => 'pass no content', _default => 'content', ); my $xr = XML::Rules->new( rules => \@rules ); $xr->parsefile('tmp.xml');

Replies are listed 'Best First'.
Re^2: TWIGging XML to CSV: what's wrong with my syntax?
by tinker (Initiate) on Apr 11, 2015 at 01:37 UTC

    Thanks Runrig! This looks very nice. I've installed XML::Rules and tried running this code but I get an error:

    no element found at line 1, column 0, byte 0 at /usr/local/share/perl/5.18.2/XML/Rules.pm line 745.
      That sounds more like your XML file is invalid...did you use my hard-coded filename above instead of your actual file name?