title: How to parse/extract a list of values from a deeply nested XML file using Perl
body: <p><strong>How can I parse/extract a list of values from an XML file with well nested values?</strong></p>
  
  <p>I have tried XML Simple and I am only able to extract the first value from a list of over 10 values. I am trying to first select seriesName "Temperature" and extract the values under that group.</p>
  
  <p><strong>This is the XML file I am parsing T124.xml</strong> (I HAVE MADE THIS A DIGESTED AS ITS A HUGE FILE):</p>
  
  <pre><code>&lt;chart caption="" subcaption="" palette="6" yAxisMinVal="11800" yAxisMaxVal=17800"xmlns="http: "&gt;
  &lt;categories&gt;
  &lt;category label=""/&gt;
  &lt;category label=""/&gt;
  &lt;category label=""/&gt;
  &lt;category label=""/&gt;
  &lt;category label=""/&gt;
  &lt;category label="6"/&gt;
  &lt;category label=""/&gt;
  &lt;category label=""/&gt;
  &lt;category label=""/&gt;
  &lt;category label=""/&gt;
  &lt;category label="12"/&gt;
  &lt;category label=""/&gt;
  &lt;category label=""/&gt;
  &lt;category label="18"/&gt;
  &lt;category label=""/&gt;
  &lt;category label=""/&gt;
  &lt;category label="21"/&gt;
  &lt;category label=""/&gt;
  &lt;/categories&gt;
  - &lt;dataset seriesName="Temperature" color="003366"&gt;
  &lt;Set value=675.0"/&gt;
  &lt;Set value=613.0"/&gt;
  &lt;Set value=612.0"/&gt;
  &lt;Set value=614.0"/&gt;
  &lt;Set value=613.0"/&gt;
  &lt;Set value=413.0"/&gt;
  &lt;Set value=613.0"/&gt;
  &lt;Set value=313.0"/&gt;
  &lt;Set value=213.0"/&gt;
  &lt;Set value=653.0"/&gt;
  &lt;Set value=633.0"/&gt;
  &lt;Set value=623.0"/&gt;
  &lt;/dataset&gt;
  &lt;dataset seriesName="Precipitation" color="66CC33"&gt;
  &lt;set value="50.6"/&gt;
  &lt;/dataset&gt;
  &lt;/chart&gt;
  </code></pre>
  
  <p><strong>Here is the Perl code I used:</strong></p>
  
  <pre><code>#!/usr/bin/perl
  use strict; 
  use XML::Simple 'XMLin';
  use Data::Dumper;
  
  my $parse = XMLin('T124.xml',forcearray =&gt; ['value']);
  #print Dumper($parse);
  
  foreach my $dataset (@{$parse-&gt;{dataset}}) {
      if ($dataset-&gt;{seriesName} eq 'Temperature') {
          print $dataset-&gt;{seriesName} . "\n";
          print $dataset-&gt;{set}-&gt;[0]-&gt;{value} . "\n";
      }
  }
  </code></pre>
  
  <p><strong>I would like to see the following output (shown below), however I am only able to extract the first 675.0 value ONLY:</strong></p>
  
  <pre><code>Temperature
  675.0 
  613.0
  612.0
  614.0
  613.0 
  </code></pre>
  
  <p>ETC...</p>