The xml attribute "id" seems to be a protected attribute. What config needed to be able to set it?

StackOverflow https://stackoverflow.com/questions/14832349

  •  09-03-2022
  •  | 
  •  

Question

I am using the perl module XML::Simple to create an XML structure. Everything works fine except that the string "<tag1 id="5"> ABC </tag1>" looks like <tag1 name="5"> ABC </tag1> afterwards.

I use the string with XML::Simple as follows

my $simple = XML::Simple->new();
my $tree = $simple->XMLin($my_xml_string, ForceArray => 1);

$resp->data()->{'xml'} = $tree;

The xml attribute id seems to be a protected attribute, because i get name in the output .

What config is needed to be able to set it?

Was it helpful?

Solution

Look at the KeyAttr option. You probably want KeyAttr => [] to de-activate array to hash folding

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top