This queue is for tickets about the XML-Simple CPAN distribution.

Report information
The Basics
Id:
29896
Status:
rejected
Priority:
Low/Low
Queue:

People
Owner:
Nobody in particular
Requestors:
joni.laaksonen [...] gmail.com
Cc:
AdminCc:

BugTracker
Severity:
(no value)
Broken in:
(no value)
Fixed in:
(no value)



MIME-Version: 1.0
X-Spam-Status: No, hits=-2.6 required=8.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VERIFIED,DK_SIGNED,HTML_MESSAGE,SPF_PASS
X-Virus-Checked: Checked
Content-Type: multipart/alternative; boundary="----=_Part_52582_9030311.1192026425103"
Received: from la.mx.develooper.com (x1.develooper.com [63.251.223.170]) by diesel.bestpractical.com (Postfix) with SMTP id 2F7D14D80A5 for <bug-XML-Simple@rt.cpan.org>; Wed, 10 Oct 2007 10:47:26 -0400 (EDT)
Received: (qmail 12312 invoked by alias); 10 Oct 2007 14:27:25 -0000
Received: from py-out-1112.google.com (HELO py-out-1112.google.com) (64.233.166.179) by la.mx.develooper.com (qpsmtpd/0.28) with ESMTP; Wed, 10 Oct 2007 07:27:17 -0700
Received: by py-out-1112.google.com with SMTP id u77so410276pyb for <bug-XML-Simple@rt.cpan.org>; Wed, 10 Oct 2007 07:27:06 -0700 (PDT)
Received: by 10.65.81.10 with SMTP id i10mr1627793qbl.1192026425112; Wed, 10 Oct 2007 07:27:05 -0700 (PDT)
Received: by 10.64.196.16 with HTTP; Wed, 10 Oct 2007 07:27:05 -0700 (PDT)
Delivered-To: cpan-bug+xml-simple@diesel.bestpractical.com
Subject: Bug in XMLout
Return-Path: <joni.laaksonen@gmail.com>
Domainkey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:mime-version:content-type; b=tl4tjBAjbfRIsU4lQ4MdrIUYgIC/bNtklO1rSTg2QfsJyNGAYtM5kLaHm24yFuphEUHsxjCuDVWViURw7j+smCtfpOgNWeGjK2FjiiFGjs1w8egDg+N/dPxYGofOdJ+WxCEtXCymral6GkmRiHrtfsYRMHuY5yH7mRkhhEwkQZY=
X-Original-To: bug-XML-Simple@rt.cpan.org
X-Spam-Check-BY: la.mx.develooper.com
Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:mime-version:content-type; bh=wK37KSSUtg5bfAu8o9/3iU7W4Ax4FzjRuaWeALlTUxk=; b=rEqNGjiP0FOd0YVwgIY5/Rtky74q/IGMU+q+X+g8gw0FJwhU82N8UVY/5TamCryipKvduu4rwp16Y6jDYUgY3lHuFUOYjPPe+zdzSRNuxi4ZPL6jS/GUEhRjyCHE6YnAiRjSY7PfXQm5W+mykJXY3JSUoy3RvYoEBNrWPTaHRfc=
Date: Wed, 10 Oct 2007 17:27:05 +0300
Message-Id: <b884767f0710100727j132cc4cdp29685486fca812cd@mail.gmail.com>
To: bug-XML-Simple@rt.cpan.org
From: "Joni Laaksonen" <joni.laaksonen@gmail.com>
Content-Length: 0
content-type: text/plain; charset="utf-8"
Content-Disposition: inline
Content-Transfer-Encoding: 7bit
X-RT-Original-Encoding: ISO-8859-1
Content-Length: 1910
Content-Type: text/html; charset=ISO-8859-1
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
X-RT-Original-Encoding: ISO-8859-1
Content-Length: 5296
Hi.
 
I wonder if I found a bug from the code or if I'm using it in the wrong way. Here's what's happening:
 
-------------------------------------------------------------------------------------
First: my $hashref = $parser->XMLin($file, KeepRoot => 1);
$file contains:
 
<settings>
  <test_1>
    <test_2>
      <test_3>
        <test_4>abcd</test_4>
        <test_5>1234</test_5>
      </test_3>
    </test_2>
  </test_1>
</settings>
 
-------------------------------------------------------------------------------------
Second: print Dumper $xmlref;
Result:
 
$VAR1 = {
          'settings' => {
                          'test_1' => {
                                        'test_2' => {
                                                      'test_3' => {
                                                                    'test_4' => 'abcd',
                                                                    'test_5' => '1234'
                                                                  }
                                                    }
                                      }
                        }
        };
 
-------------------------------------------------------------------------------------
Third: my $xml = XMLout( $hashref, AttrIndent => 1, KeepRoot => 1, NoAttr => 1 );  print Dumper $xml;
Result:
 
$VAR1 = '<settings>
  <test_1>
    <name>test_2</name>
    <test_3>
      <test_4>abcd</test_4>
      <test_5>1234</test_5>
    </test_3>
  </test_1>
</settings>
';
 
-------------------------------------------------------------------------------------
Fault:
Nested <test_2> has turned into <name>test_2</name>.
 
-------------------------------------------------------------------------------------
Environment:
 
# $Id: Simple.pm,v 1.40 2007/08/15 10:36:48 grantm Exp $  ($VERSION           = '2.18';)
This is perl, v5.6.1 built for MSWin32-x86-multi-thread  (ActiveState)
 
- Joni
MIME-Version: 1.0
In-Reply-To: <b884767f0710100727j132cc4cdp29685486fca812cd@mail.gmail.com>
X-Mailer: MIME-tools 5.418 (Entity 5.418)
Content-Disposition: inline
Message-Id: <rt-3.6.HEAD-6562-1192046315-1155.29896-0-0@rt.cpan.org>
References: <b884767f0710100727j132cc4cdp29685486fca812cd@mail.gmail.com>
Content-Type: text/plain; charset="utf8"
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
X-RT-Original-Encoding: utf-8
Content-Length: 742
The introduction of the 'name' element is due to the default value of the KeyAttr option. If you're trying to round-trip XML then you will at the very least want to set the ForceArray option as well. However, if you want to round-trip XML then you're probably better off with a module like XML::LibXML which retains much more information about the source document in it's DOM object. XML::Simple's simplicity comes from the fact that it discards a lot of information from the source XML document. If you want to persist with XML::Simple, please read this article: http://www.perlmonks.org/index.pl?node_id=218480 If you want to look at XML::LibXML then this article may be useful: http://www.perlmonks.org/index.pl?node_id=490846


This service runs on Request Tracker, is sponsored by The Perl Foundation, and maintained by Best Practical Solutions.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.