use XML::Simple qw(:strict); my $xml = XMLin($tmpfile, ForceArray => 0, SuppressEmpty => 1, KeyAttr => 'ru_resource' ); my $bandwidth = $xml->{exec_command}->{xml_show_result}->{xml_show_resource_usage}->{ru_entry}->{bandwidth}->{ru_current}; print $bandwidth;