Parsing a Soap Response

General discussions and other topics.
2 posts Page 1 of 1
by Steve Kucera » Fri Jul 12, 2013 1:01 pm
I'm still pretty new to xml and SOAP and need assistance parsing the following data ( from Dumper($data) ):

$VAR1 = {
'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
'soap:Body' => {
'PurchasePinResponse' => {
'xmlns' => 'http://www.pininteract.com',
'orderResponse' => {
'xmlns' => 'urn:pininteract.com',
'invoice' => {
'invoiceAmount' => '45.000',
'faceValueAmount' => '50.00',
'cards' => {
'card' => {
'skuId' => '199',
'pins' => {
'pin' => {
'pinNumber' => '50489898515256',
'controlNumber' => '111111111111'
}
},
'name' => 'Simple Mobile',
'faceValue' => '50.00'
}
},
'invoiceNumber' => '4515563',
'transactionDateTime' => '2013-07-12T11:30:07.17'
},
'responseCode' => '000',
'version' => '1.0'
}
}
},
'xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema',
'xmlns:soap' => 'http://schemas.xmlsoap.org/soap/envelope/'
};

I need to extract the PIN number to store it in a database.

I know the syntax should be something along the lines of:

$something->{more_something}->{more_something}

I am in a pinch and not getting it done. If anyone can help me I would appreciate it. Once I see it I will be able to see how you arrived at the solution.

Thanks.
by toast0 » Mon Jul 15, 2013 9:14 pm
it's hard to tell without indentation; but it looks like you want
$VAR1->{'soap:Body'}{'PurchasePinResponse'}{'orderResponse'}{'invoice'}{'cards'}{'card'}{'pins'}{'pin'}{'pinNumber'}

Yay SOAP! You need to be a bit more careful about the xml parsing if cards or pins could ever have more than one card or pin (There are ways to tell the perl XML parser what's an array and what isn't...)
2 posts Page 1 of 1

Who is online

In total there are 2 users online :: 0 registered, 0 hidden and 2 guests (based on users active over the past 5 minutes)
Most users ever online was 999 on Mon May 10, 2021 1:02 am

Users browsing this forum: No registered users and 2 guests