$xml = <<'*END*' ... ... ...
... ... ... ...
... ... ...
... ... ... ...
*END* %rules = ( _default => sub {$_[0] => $_[1]->{_content}}, # by default we are only interested in the content and we want # the parent to access it as an attribute of the same name as was the tag bogus => undef, # means "ignore" address => sub {address => "$_[1]->{street}, $_[1]->{city} ($_[1]->{country})"}, # let's convert the address to a single string person => sub {'@person' => "$_[1]->{lname}, $_[1]->{fname}\n<$_[1]->{email}>\n$_[1]->{address}"} # push the stringified data into the @{$parent->{person}} doc => sub { join( "\n\n", @{$_[1]->{person}})} ); print XML::TransformRules::Parse( $xml, \%rules);