mitchismoney has asked for the wisdom of the Perl Monks concerning the following question:
New Monk seeking wisdom about parsing a soap response.
I have a soap response from a VB Script that saves as XML. I would like to grab this file with PERL, parse it and store it in a database, either in full XML string or parsed by element. My problem is that the output I'm getting from XML::Parse is not very friendly. I think its an encoding issue but I'm not sure how to get around it.
Thanks for the responses, I spaced out on posting the PERL code. Ultimately I would like to see something like:<?xml version='1.0' encoding='UTF-8'?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <SOAP-ENV:Body> <ns1:VHIResponse xmlns:ns1="http://tempuri.org/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" +> <return xsi:type="xsd:string"> <Vehicles> <Vehicle vin="1FMFU17L94LB04622"> <Status desc="Vehicle status OK" id="VI1000"/&g +t; <VehicleAttributes> <VehicleAttribute type="Year" typeid="14" value +="2004" valueid="3043"/> <VehicleAttribute type="Make" typeid="1" value= +"Ford" valueid="184"/> <VehicleAttribute type="Model" typeid="2" value +="Expedition" valueid="30"/> <VehicleAttribute type="Series" typeid="3" valu +e="Eddie Bauer" valueid="117"/> </VehicleAttributes> </Vehicle> </Vehicles> </return> </ns1:VHIResponse> </SOAP-ENV:Body> </SOAP-ENV:Envelope>
All I really need extracted is the VIN/Make/Model/Year and Series from the resulting response. I am relatively new to this so I'm starting out slow with the basics:<FCSDServicesResponse country="USA" language="ENG" marketid="1"> <Status desc="Web service status OK" id="VI2000"/> <Vehicles> <Vehicle vin="1FMFU17L94LB04622"> <Status desc="Vehicle status OK" id="VI1000"/> <VehicleAttributes> <VehicleAttribute type="Year" typeid="14" value="2004" valueid="3043"/ +> <VehicleAttribute type="Make" typeid="1" value="Ford" valueid="184"/> <VehicleAttribute type="Model" typeid="2" value="Expedition" valueid=" +30"/> <VehicleAttribute type="Series" typeid="3" value="Eddie Bauer" valueid +="117"/> </VehicleAttributes> </Vehicle> </Vehicles> </FCSDServicesResponse>
What I get from this is:# use module use XML::Simple; use Data::Dumper; # create object $xml = new XML::Simple; # read XML file $data = $xml->XMLin("Elvis1.xml"); # print output print Dumper($data);
Many Thanks in advance. Darren$VAR1 = { 'country' => 'USA', 'language' => 'ENG', 'Status' => { 'desc' => 'Web service status OK', 'id' => 'VI2000' }, 'Vehicles' => { 'Vehicle' => { 'VehicleAttributes' => { 'VehicleAt +tribute' => [ + { + 'typeid' => '14', + 'value' => '2004', + 'valueid' => '3043', + 'type' => 'Year' + }, + { + 'typeid' => '1', + 'value' => 'Ford', + 'valueid' => '184', + 'type' => 'Make' + }, + { + 'typeid' => '2', + 'value' => 'Expedition', + 'valueid' => '30', + 'type' => 'Model' + }, + { + 'typeid' => '3', + 'value' => 'Eddie Bauer', + 'valueid' => '117', + 'type' => 'Series' + } + ] }, 'Status' => { 'desc' => 'Vehicle st +atus OK', 'id' => 'VI1000' }, 'vin' => '1FMFU17L94LB04622' } }, 'marketid' => '1' };
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: XML SOAP Response
by ambrus (Abbot) on Jul 31, 2008 at 16:56 UTC | |
Re: XML SOAP Response
by psini (Deacon) on Jul 31, 2008 at 16:59 UTC | |
by mitchismoney (Initiate) on Jul 31, 2008 at 17:23 UTC | |
Re: XML SOAP Response
by moritz (Cardinal) on Jul 31, 2008 at 16:54 UTC | |
Re: XML SOAP Response
by olus (Curate) on Jul 31, 2008 at 16:54 UTC | |
Re: XML SOAP Response
by psini (Deacon) on Jul 31, 2008 at 17:30 UTC | |
by mitchismoney (Initiate) on Jul 31, 2008 at 17:46 UTC | |
by almut (Canon) on Jul 31, 2008 at 17:55 UTC | |
by psini (Deacon) on Jul 31, 2008 at 18:23 UTC | |
by psini (Deacon) on Jul 31, 2008 at 17:49 UTC |
Back to
Seekers of Perl Wisdom