use XML::Rules; my $parser = XML::Rules->new(rules => {}, ident => ' '); print $parser->toXML( Shelf_Info => { switch => [ {Name => "Puebla01", shelfType => [7480], commentText => ['ATM Core switch']}, {Name => "Puebla02", shelfType => [7440], commentText => ['ATM access switch']}, ] });