####
##
##
##
##
##
##
my $xs = XML::Simple->new(
forcearray => [ 'item' ],
keyattr => { item => 'id' },
rootname => 'opt',
);
my $opt = $xs->XMLin(\*DATA);
##
##
$opt->{trans}->{item}->{1}
##
##
$opt->{trans}->{item}->{2} = { status => 'contacted', assignee => 'jill' };
##
##
#!/usr/bin/perl -w
use strict;
use XML::Simple;
my $xs = XML::Simple->new(
forcearray => [ 'item' ],
keyattr => { item => 'id' },
rootname => 'opt',
);
my $opt = $xs->XMLin(\*DATA);
$opt->{trans}->{item}->{2} = { status => 'contacted', assignee => 'jill' };
print $xs->XMLout($opt);
__DATA__
##
##
$opt->{trans}->{item}->[0]
##
##
@{ $opt->{trans}->{item} }
##
##
my $id = @{ $opt->{trans}->{item} } + 1;
push @{ $opt->{trans}->{item} }, { id => $id, status => 'contacted', assignee => 'jill' };
##
##
#!/usr/bin/perl -w
use strict;
use XML::Simple;
my $xs = XML::Simple->new(
forcearray => [ 'item' ],
keyattr => { },
rootname => 'opt',
);
my $opt = $xs->XMLin(\*DATA);
my $id = @{ $opt->{trans}->{item} } + 1;
push @{ $opt->{trans}->{item} }, { id => $id, status => 'contacted', assignee => 'jill' };
print $xs->XMLout($opt);
__DATA__