title: Parsing complex XML in Perl
body: <p>I have an  XML and I want to print all his nodes and I want to access the movie nodes fields.</p>
  
  <p>I can access Name and City, but I can`t access Movie fields.</p>
  
  <pre><code>&lt;OnlineCinema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Cinema.xsd"&gt;
  &lt;Cinema&gt;
      &lt;City&gt;Cluj&lt;/City&gt;
      &lt;Name&gt;Cinema2&lt;/Name&gt;
      &lt;MovieName&gt;ScaryMovie&lt;/MovieName&gt;
      &lt;Movie&gt;
          &lt;Name&gt;ScaryMovie&lt;/Name&gt;
          &lt;Genre&gt;comedie&lt;/Genre&gt;
          &lt;Director&gt;lala&lt;/Director&gt;
          &lt;Writer&gt;asdf&lt;/Writer&gt;
          &lt;Cast&gt;asdvvb&lt;/Cast&gt;
          &lt;Year&gt;2010&lt;/Year&gt;
          &lt;Trailer&gt;http://www.youtube.com/embed/RMDZ8M47j0I&lt;/Trailer&gt;
          &lt;NRLoc&gt;400&lt;/NRLoc&gt;
      &lt;/Movie&gt;
  &lt;/Cinema&gt;
  </code></pre>
  
  <p>Code:</p>
  
  <pre><code>use XML::Simple;
  use Data::Dumper;
  
  $xml = new XML::Simple (KeyAttr=&gt;[]);
  $data = $xml-&gt;XMLin("OnlineCinema.xml");
  print "Content-type: text/html \n\n";
  
  foreach $e (@{$data-&gt;{Cinema}}) {
      print "City: ", $e-&gt;{City}, "&lt;/br&gt;\n";
      print "Name: ", $e-&gt;{Name}, "&lt;/br&gt;\n"; 
      print "&lt;/br&gt;&lt;/br&gt;\n";
  }
  </code></pre>