Hi
I'm struggling with the use of XML::Simple so was hoping that someone
might be able to help me. I'm kind of new to perl, especially when
dealing with hash references. I would like to iterate through the hash
that is created by the XMLIn function. Here is my code:
    use Env qw(GMNHOME GMNSQLSRVR GVHOME);
    use XML::Simple;
    use Data::Dumper;
    $ref = XMLin("$HOME/tmp/foo.xml");
    $FirstReject = $ref->{RejectRecord}->[0]->{Reason};
    print "First Reject is $FirstReject \n";

The a sample of the contents of the XML file is found below: Notice
that I've hardcode the first reference to Rejected Records by using
[0]. Well I need to know how of these there are in the hashref $ref so
I can iterate through. Any help would be much appreciated. Thanks in
advance.
Ray

XML File foo.xml
<RejectRecords>
  <RejectRecord>
    <Reason>FAILURE: Attempt to add Customer has failed</Reason>
    <Customer_New>
      <Code>LarryBoy</Code>
    </Customer_New>
    <Code>1234</Code>
  </RejectRecord>
  <RejectRecord>
    <Reason>FAILURE: Attempt to add Customer has failed</Reason>
    <Customer_New>
      <Code>JimBob</Code>
    </Customer_New>
    <Code>1234</Code>
  </RejectRecord>
 </RejectRecords>


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to