Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

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

by runrig (Abbot)
on Apr 10, 2015 at 21:24 UTC ( [id://1123080]=note: print w/replies, xml ) Need Help??


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?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1123080]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (4)
As of 2024-03-28 08:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found