Loading ...
Sorry, an error occurred while loading the content.

Accessing xml attributes

Expand Messages
  • Dave Kimberley
    I have written a SOAP client using soaplite and I am having a probelm accessing part of the xml data. I use the following code to access employees: #========
    Message 1 of 2 , Mar 19, 2003
    View Source
    • 0 Attachment
      I have written a SOAP client using soaplite and I am having a probelm
      accessing part of the xml data.

      I use the following code to access employees:

      #========
      my @Employees =
      $MessageDetailSOM->valueof('//GovTalkMessage/Body/DigitalMail/MessageBody/CodingNoticesP6P6B/Employe
      e');
      foreach my $Employee (@Employees)
      {
      print "NINO: ", $Employee-{'NINO'}, "\n";
      print "TaxCode: ", $Employee->{'CodingUpdate'}->{'TaxCode'}, "\n";
      print "TaxCodeWeek1Month1Indicator: ",
      $Employee->{'CodingUpdate'}->{'TaxCode@Week1Month1Indicator'}, "\n";
      }
      #========

      I can't access the Week1Month1Indicator. How do I access this value?

      An example of the XML being processed:

      <Employee>
      <Name>
      <Title>Dr</Title>
      <Forename>James</Forename>
      <Surname>Bacon</Surname>
      </Name>
      <NINO>AB123456A</NINO>
      <WorksNumber>5216311Y</WorksNumber>
      <EffectiveDate>2001-09-19</EffectiveDate>
      <CodingUpdate>
      <TaxCode Week1Month1Indicator="X">433L</TaxCode>
      <TotalPreviousPay Currency="GBP">25000.00</TotalPreviousPay>
      <TotalPreviousTax Currency="GBP">12500.50</TotalPreviousTax>
      </CodingUpdate>
      </Employee>

      Thanks

      Dave
    • Randy J. Ray
      Look at the dataof() method under the SOAP::SOM section of manual page. If you get your data back in the form of a SOAP::Data object rather than as a native
      Message 2 of 2 , Mar 19, 2003
      View Source
      • 0 Attachment
        Look at the dataof() method under the "SOAP::SOM" section of manual page. If
        you get your data back in the form of a SOAP::Data object rather than as a
        native Perl hash, you can get the attributes.

        Randy
        --
        """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
        Randy J. Ray Campbell, CA http://www.rjray.org rjray@...

        Silicon Valley Scale Modelers: http://www.svsm.org
      Your message has been successfully submitted and would be delivered to recipients shortly.