Did you think you could avoid the inevitable? Here is how someone from New Hampshire would solve this using XML::Twig! I guess grantm will have more on the way you use XML::Simple ;--)

XML::Twig is quite appropriate here because it lets you specify quite easily that you only want to process header elements with a specific attribute name, and it will only load the relevant part of the document, instead of the entire thing.

#!/usr/bin/perl -w -l use strict; use XML::Twig; my $name= live_free() or die; my $t= XML::Twig->new( twig_roots => { qq{header[\@name="$name"]} => \&print_content + }, ); $t->parse( \*DATA); sub print_content { my( $t, $header)= @_; print join( "\n", map { $_->text } $header->children); } sub live_free { return shift @ARGV; } __DATA__ <?xml version="1.0"?> <!-- This is XML for the Header Mapping --> <map> <header name="ABCstatus"> <act>WTO</act> </header> <header name="ABCevent"> <act>WTO</act> <act>Call</act> </header> <header name="DEF-Call"> <act>Call</act> </header> <header name="Unknown"> <act>WTO</act> <act>SMS</act> <act>NetSend</act> </header> </map>

In reply to Re: XML::Simple parsing by mirod
in thread XML::Simple parsing by AcidHawk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.