Subject: | XMLin keyattr=> default with name |
Hi
The subject is not clear but I hope my eample will be more.
I'm not sure if you intent to do that, but it looks that XMLIn take the
"name" sub element as a default attribute .
If you have a look at the attached 99_nonunique.t, the third example
produces a warning showing that. (see test output at the end)
It does not produce the warning if keyattr=>{} or if the "name" sub
element is renamed "hahaname"
I think it was not the case with 2.14 (not sure)
cheers
Alex
PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e"
"test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/99_nonunique....1/3 Warning: <item> element has non-unique value in
'name' key attribute: color at t/99_nonunique.t line 34
t/99_nonunique....ok
All tests successful.
Files=1, Tests=3, 0 wallclock secs ( 0.02 usr 0.00 sys + 0.09 cusr
0.01 csys = 0.12 CPU)
Result: PASS
Subject: | 99_nonunique.t |
use strict;
use Test::More;
use IO::File;
use File::Spec;
use XML::Simple;
plan tests => 3;
$^W = 1;
my $xitems = q(<opt>
<item hahaname="color">red</item>
<item hahaname="color">green</item>
</opt>);
my $opt = XMLin($xitems);
ok($opt);
$xitems = q(<opt>
<item name="color">red</item>
<item name="color">green</item>
</opt>);
$opt = XMLin($xitems, keyattr => {});
ok($opt);
$xitems = q(<opt>
<item name="color">red</item>
<item name="color">green</item>
</opt>);
$opt = XMLin($xitems);
ok($opt);