#!/usr/bin/perl --
use strict; use warnings;
use XML::Rules;
use Data::Dump qw/ dd /;
my $wanted = <<'__XML__';
joe
user
mary
user
__XML__
use XML::Rules;
my $t = XML::Rules->new(
qw/ stripspaces 8 /,
rules => {
'dev0,devices,key0,key1,opt' => 'no content',
'param' => 'as array',
},
);
my $XmlRef = $t->parse( $wanted );
dd $XmlRef;
print $t->toXML( opt => $XmlRef->{opt}, undef, " ", );
__END__
{
opt => {
key0 => {
devices => {
dev0 => {
param => [
{ _content => "joe", id => "name" },
{ _content => "user", id => "type" },
],
},
},
},
key1 => {
devices => {
dev0 => {
param => [
{ _content => "mary", id => "name" },
{ _content => "user", id => "type" },
],
},
},
},
},
}
joe
user
mary
user