title: How to parse multi record XML file ues XML::Simple in Perl
body: <p>My data.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="ISO-8859-1"?&gt;
  &lt;catalog&gt;
    &lt;cd country="UK"&gt;
      &lt;title&gt;Hide your heart&lt;/title&gt;
      &lt;artist&gt;Bonnie Tyler&lt;/artist&gt;
      &lt;price&gt;10.0&lt;/price&gt;
    &lt;/cd&gt;
    &lt;cd country="CHN"&gt;
      &lt;title&gt;Greatest Hits&lt;/title&gt;
      &lt;artist&gt;Dolly Parton&lt;/artist&gt;
      &lt;price&gt;9.99&lt;/price&gt;
    &lt;/cd&gt;
    &lt;cd country="USA"&gt;
      &lt;title&gt;Hello&lt;/title&gt;
      &lt;artist&gt;Say Hello&lt;/artist&gt;
      &lt;price&gt;0001&lt;/price&gt;
    &lt;/cd&gt;
  &lt;/catalog&gt;
  </code></pre>
  
  <p>my test.pl</p>
  
  <pre><code>#!/usr/bin/perl
  
     # use module
     use XML::Simple;
     use Data::Dumper;
  
     # create object
     $xml = new XML::Simple;
  
     # read XML file
     $data = $xml-&gt;XMLin("data.xml");
  
     # access XML data
     print "$data-&gt;{cd}-&gt;{country}\n";
     print "$data-&gt;{cd}-&gt;{artist}\n";
     print "$data-&gt;{cd}-&gt;{price}\n";
     print "$data-&gt;{cd}-&gt;{title}\n";
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>Not a HASH reference at D:\learning\perl\t1.pl line 16.
  </code></pre>
  
  <p>Comment: I googled and found the article(handle single xml record). 
  <a href="http://www.go4expert.com/forums/showthread.php?t=812" rel="nofollow noreferrer">http://www.go4expert.com/forums/showthread.php?t=812</a>
  I tested with the article code, it works quite well on my laptop.</p>
  
  <p>Then I created my practice code above to try to access multiple record. but failed. How can I fix it? Thank you.</p>