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.
<?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>
Thanks for the responses, I spaced out on posting the PERL code.
Ultimately I would like to see something like:
<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>
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:
# 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);
What I get from this is:
$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'
};
Many Thanks in advance.
Darren