#!/usr/bin/perl -- use strict; use warnings; my $response_xml = <<'__RESPONSE__'; <?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" x +mlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schema +s.xmlsoap.org/soap/envelope/"> <soap:Body> <get_ManufacturerListResponse xmlns="http://webservice.isolda.se/S +tandard"> <get_ManufacturerListResult> <StatusID>int</StatusID> <StatusMessage>string</StatusMessage> <InputString>string</InputString> <Results>int</Results> <Generated>dateTime</Generated> <Manufacturers> <Manufacturer ManufacturerCode="HP" /> <Manufacturer ManufacturerCode="Lexmark" /> </Manufacturers> </get_ManufacturerListResult> </get_ManufacturerListResponse> </soap:Body> </soap:Envelope> __RESPONSE__ for($response_xml){ s/^s*//; s/\s*$//; } use XML::Simple; use Data::Dumper; $Data::Dumper::Indent=1; print Dumper( XMLin( $response_xml )), $/,'----',$/; use SOAP::Lite; my $d = SOAP::Custom::XML::Deserializer->deserialize( $response_xml ); print $d->valueof('/Envelope/Body'), $/,'----',$/; print 'statusid ', $d->valueof('//get_ManufacturerListResult/StatusID' +), $/,'----',$/; print $d->dataof('//get_ManufacturerListResult/Manufacturers/Manufactu +rer')->attr->{'ManufacturerCode'}; print $/,'----',$/; for my $t ($d->valueof('//get_ManufacturerListResult/Manufacturers/Man +ufacturer' ) ){ print $t->attr->{'ManufacturerCode'}; # print Dumper( $t ); } __END__ $VAR1 = { 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', 'soap:Body' => { 'get_ManufacturerListResponse' => { 'xmlns' => 'http://webservice.isolda.se/Standard', 'get_ManufacturerListResult' => { 'StatusID' => 'int', 'Manufacturers' => { 'Manufacturer' => [ { 'ManufacturerCode' => 'HP' }, { 'ManufacturerCode' => 'Lexmark' } ] }, 'InputString' => 'string', 'Results' => 'int', 'StatusMessage' => 'string', 'Generated' => 'dateTime' } } }, 'xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema', 'xmlns:soap' => 'http://schemas.xmlsoap.org/soap/envelope/' }; ---- int ---- statusid int ---- HP ---- HPLexmark

In reply to Re^3: SOAP::Lite - Attribute in array by Anonymous Monk
in thread SOAP::Lite - Attribute in array by DreamT

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.