I’m using Guzzle to call the USPS Address Validation Service, and getting XML in the response. I then get the body from the XML using the following:
$body = $response->getBody();
Which produces the following:
<AddressValidateResponse>
    <Address ID="0">
        <Error>
            <Number>-2147219400</Number>
            <Source>clsAMS</Source>
            <Description>Invalid City.  </Description>
            <HelpFile/>
            <HelpContext/>
        </Error>
    </Address>
</AddressValidateResponse> 
I need to parse that to get the Description.
$body is currently an Object. I tried casting it to an Array, but get the following, which is not what I’m after:
array (
  '' . "\0" . 'GuzzleHttp\\Psr7\\Stream' . "\0" . 'stream' => NULL,
  '' . "\0" . 'GuzzleHttp\\Psr7\\Stream' . "\0" . 'size' => NULL,
  '' . "\0" . 'GuzzleHttp\\Psr7\\Stream' . "\0" . 'seekable' => true,
  '' . "\0" . 'GuzzleHttp\\Psr7\\Stream' . "\0" . 'readable' => true,
  '' . "\0" . 'GuzzleHttp\\Psr7\\Stream' . "\0" . 'writable' => true,
  '' . "\0" . 'GuzzleHttp\\Psr7\\Stream' . "\0" . 'uri' => 'php://temp',
  '' . "\0" . 'GuzzleHttp\\Psr7\\Stream' . "\0" . 'customMetadata' => 
  array (
  ),
)  
Does anyone know how I can parse that $body to get the Description Node?
Thanks for any guidance!
 
     
    