<?xml version="1.0" encoding="windows-1252"?>
<node id="590000" title="Re^4: Forcing to anonymous array in XML::simple" created="2006-12-15 04:33:17" updated="2006-12-14 23:33:17">
<type id="11">
note</type>
<author id="56927">
rbi</author>
<data>
<field name="doctext">
Thanks. I'm trying to cope in a general way with these situations:
&lt;code&gt;
use strict;
use warnings;
use XML::Simple;use Data::Dumper;
my $file = './test.xml';

my $a = ['x','y'];
my $a1 = [$a];
my %tmp = ( A =&gt;$a1, B =&gt; 'z');
XMLout(\%tmp,outputfile=&gt;$file,noattr=&gt;1);
%tmp = %{XMLin($file,forcearray=&gt;['A'],noattr=&gt;1)};
print "----------\n";
print $tmp{B}."\n";
print $tmp{A}[0]-&gt;[0]."\n";

$a = ['x'];
$a1 = [$a];
%tmp = ( A =&gt;$a1, B =&gt; 'z');
XMLout(\%tmp,outputfile=&gt;$file,noattr=&gt;1);
%tmp = %{XMLin($file,forcearray=&gt;1,noattr=&gt;1)};
print "----------\n";
print $tmp{B}."\n";
print $tmp{A}[0]-&gt;[0]."\n";

$a = ['x'];
$a1 = [$a];
%tmp = ( A =&gt;$a1, B =&gt; 'z');
XMLout(\%tmp,outputfile=&gt;$file,noattr=&gt;1);
%tmp = %{XMLin($file,forcearray=&gt;['A'],noattr=&gt;1)};
print "----------\n";
print $tmp{B}."\n";
print $tmp{A}[0]-&gt;[0]."\n";

&lt;/code&gt;
That outputs:&lt;br&gt;
&lt;code&gt;
----------
z
x
----------
ARRAY(0x653930)
x
----------
z
Not an ARRAY reference at tmp1.pl line 31.
&lt;/code&gt;
I can only think of evaluating &lt;code&gt;ref($tmp{A})&lt;/code&gt; and &lt;code&gt;ref($tmp{B})&lt;/code&gt; to decide how to operate, since in my code &lt;code&gt;$tmp{A}&lt;/code&gt; is an array reference to an array that can have a single element made by an array reference to a single-element array itself, and &lt;code&gt;$tmp{B}&lt;/code&gt; is instead a  scalar. I guess I'm missing something...</field>
<field name="root_node">
589844</field>
<field name="parent_node">
589889</field>
</data>
</node>
