Hi, I have just started to study XML::Study module. below is my script.

use warnings; #use strict; use XML::Simple; use Data::Dumper; my $xml = XML::Simple->new(); my $data = $xml->XMLin("data1.xml"); print Dumper($data);

and here is my xml file.

<?xml version='1.0'?> <employees> <employee> <name>John Doe</name> <age>43</age> <sex>M</sex> <department>Operations</department> </employee> <employee> <name>Jane Doe</name> <age>31</age> <sex>F</sex> <department>Accounts</department> </employee> </employees>

output what tutorials are getting (which seems correct) is

$data = { 'employee' => [ { 'department' => 'Operations', 'name' => 'John Doe', 'sex' => 'M', 'age' => '43' }, { 'department' => 'Accounts', 'name' => 'Jane Doe', 'sex' => 'F', 'age' => '31' } ] };

& what I am getting is

$VAR1 = { 'employee' => { 'John Doe' => { 'department' => 'Operations', 'age' => '43', 'sex' => 'M' }, 'Jane Doe' => { 'department' => 'Accounts', 'age' => '31', 'sex' => 'F' } } };

why this mismatch..please help.. I installed module using cpan command prompt method...I am not root just a user.. and working on ubuntu...thanx


In reply to XML::Simple Not getting the proper output. by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.