 <p>You've an answer how to do this with XML::Simple already. But I'd suggest not, and use <code>XML::Twig</code> instead, which is MUCH less nasty. </p> <p><a href="http://stackoverflow.com/questions/33267765/why-is-xmlsimple-discouraged">Why is XML::Simple &quot;Discouraged&quot;?</a></p> <p>I'm going to assume that your XML looks a bit like this:</p> <pre><code>&lt;opt Timeout="5"&gt; &lt;Roots&gt; &lt;Root Action="Reject" Interval="Order" Level="Indeterminate" Name="Sales"&gt; &lt;Profiles&gt; &lt;Profile Age="50" Name="Bill" Status="Active" /&gt; &lt;Profile Age="24" Name="Bob" Status="Inactive" /&gt; &lt;/Profiles&gt; &lt;/Root&gt; &lt;/Roots&gt; &lt;/opt&gt; </code></pre> <p>I can't tell for sure, because that's the joy of <code>XML::Simple</code>. But:</p> <pre><code>#!/usr/bin/env perl use strict; use warnings; use XML::Twig; my $twig = XML::Twig -&gt; new -&gt; parsefile ( $configfile ); print $twig -&gt; get_xpath ( '//Profile[@Name="Bob"]',0 ) -&gt; att('Status') </code></pre> <p>This uses <code>xpath</code> to locate the attribute you desire - <code>//</code> denotes a 'anywhere in tree' search. </p> <p>But you could instead:</p> <pre><code>print $twig -&gt; get_xpath ( '/opt/Roots/Root/Profiles/Profile[@Name="Bob"]',0 ) -&gt; att('Status') </code></pre> <p>Much <em>simpler</em> wouldn't you agree? </p> <p>Or iterate all the 'Profiles':</p> <pre><code>foreach my $profile ( $twig -&gt; get_xpath ('//Profile' ) ) { print $profile -&gt; att('Name'), " =&gt; ", $profile -&gt; att('Status'),"\n"; } </code></pre>