#!/usr/bin/perl -- #~ xml-simple-to-xml-rules-1089765.pl #~ 2014-06-12-23:31:16 by Anonymous Monk #~ #~ #~ perltidy -csc -otr -opr -ce -nibc -i=4 #!/usr/bin/perl -- use strict; use warnings; use XML::Rules; use XML::Simple qw/ XMLin /; use Data::Dump qw/ dd /; my $shortxmlraw = q{ John Doe 43 M Operations Jane Doe 31 F Accounts }; my $xmlin = XML::Rules->new( qw/ stripspaces 8 /, rules => ## the result of xml2XMLRules foo.xml foo2.xml .... { 'age,department,name,sex' => 'content', 'employee' => 'as array no content', 'employees' => 'no content' }, ); dd({ YES => $xmlin->parse( $shortxmlraw ) }); dd({ NO => XMLin( $shortxmlraw ) }); __END__ { YES => { employees => { employee => [ { age => 43, department => "Operations", name => "John Doe", sex => "M" }, { age => 31, department => "Accounts", name => "Jane Doe", sex => "F" }, ], }, }, } { NO => { employee => { "Jane Doe" => { age => 31, department => "Accounts", sex => "F" }, "John Doe" => { age => 43, department => "Operations", sex => "M" }, }, }, }