#!/usr/bin/perl -w
use strict;
use XML::Simple;
use Data::Dumper;
my $self;
my $pr_no_attach_xml;
$pr_no_attach_xml = qq~
1.0
173794
223344
ABC123456
0
23
2003-10-01T23:59:59
false
0
both
1AREACODENUMBER
Me
bc-voice-1
1AREACODENUMBER
Me
bc-voice-2
~;
my $xs = XML::Simple->new(
KeepRoot => 1,
GroupTags => { voice_recipient_list => 'voice_recipient' },
KeyAttr => [ 'name' ],
);
$self->{_upload_hash} = $xs->XMLin( $pr_no_attach_xml );
print Dumper $self->{_upload_hash};
# Now modify the XML a little:
$self->{_upload_hash}->{voice_broadcast_info}->{voice_recipient_list} = [
{
'voice_recipient' => {
'voice_recipient_number' => '14169999999',
'voice_recipient_name' => 'John Day - 1',
'voice_recipient_reference' => 'bc-voice-1'
}
},
{
'voice_recipient' => {
'voice_recipient_number' => '14169999999',
'voice_recipient_name' => 'John Day - 2',
'voice_recipient_reference' => 'bc-voice-1'
}
}
];
my $xml = $xs->XMLout( $self->{_upload_hash}, attrIndent => 1 );
print "\nThrough the pipe - XML::Simple :\n\n$xml\n";
####
1AREACODENUMBER
Me
bc-voice-1
####