For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > March 2004 > bug in XML::Simple ?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author bug in XML::Simple ?
Marcos Rebelo

2004-03-26, 11:14 pm


I did this shell command

perl -e 'use XML::Simple qw(:strict); use Data::Dumper; print
Dumper(XMLin("<xxx><_a>b</_a></xxx>", 'ForceArray' => 1, KeyAttr => []))' >
delete.txt

And the output was

$VAR1 = {
'__a' => [
'b'
]
};

I was aspecting

$VAR1 = {
'_a' => [
'b'
]
};

What am I doing wrong?

Marcos
Wiggins D Anconia

2004-03-26, 11:14 pm

>
> I did this shell command
>
> perl -e 'use XML::Simple qw(:strict); use Data::Dumper; print
> Dumper(XMLin("<xxx><_a>b</_a></xxx>", 'ForceArray' => 1, KeyAttr =>

[]))' >
> delete.txt
>
> And the output was
>
> $VAR1 = {
> '__a' => [
> 'b'
> ]
> };
>
> I was aspecting
>
> $VAR1 = {
> '_a' => [
> 'b'
> ]
> };
>
> What am I doing wrong?
>


I suspect XML::Simple thinks your XML is not well formed because your
tag names start with an underscore. See point #2 here:

http://search.cpan.org/~grantm/XML-...mple.pm#Caveats

Which essentially gives it artistic license to do what it wants. Whether
this is a bug or just "you shouldn't do that it is bad for your health"
is hard to say...

In addition on my Perl 5.8.0, XML::Simple 2.0.7 on RH Linux 9, and in
Perl 5.6.1, XML::Simple 2.0.5, on Solaris 8, I get the output you expect.

http://danconia.org
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com