Question: I have a SOAP response that I am trying to parse, however I seem to be getting an error.

SOAP response:

```
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<ValidateNewUserResponse xmlns="urn:websitea.com/v2"><ValidateNewUserResult xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><Message i:nil="true"/>
<Status>true</Status>
<FailureReason>None</FailureReason>
<IdentityValidationOutcome>0</IdentityValidationOutcome>
<ValidationIdentifier>112244</ValidationIdentifier>
</ValidateNewUserResult></ValidateNewUserResponse>
</s:Body>
</s:Envelope>

```

I have tried the following code:

```
$doc = new DOMDocument();
$doc->loadXML($strXml);
echo $doc->getElementsByTagName('Status')->item(0)->nodeValue;

```

This produces the following error:

> 
> Trying to get property of non-object
> 
> 
> 

I have also tried the following code:

```
$get_xml = str_ireplace(['S-ENV:', 'S:'], '', $strResponse);
$xml = simplexml_load_string($get_xml);
$status=((string)$xml->Body->ValidateNewUserResponse->ValidateNewUserResult->Status);echo "<br />";

```

Which produces the following error:

> 
> simplexml\_load\_string(): namespace error : Namespace prefix i for nil on Message is not defined
> 
> 
>

Answer: 
Try the following, works fine for me.

```
$doc = new DOMDocument();
$doc->loadXML($strResponse);
$result = $doc->getElementsByTagName('Status')->item(0)->nodeValue;
echo $result;

```
Or you can use a WSDL to php generator so you don't have to parse the XML response nor generate the XML request as you'll always handle PHP objects. This is the case using the basic native PHP SoapClient class. You can also use a WSDL to php generator such as [PackageGenerator](https://github.com/WsdlToPhp/PackageGenerator) because it's the best way to consume SOAP in my point of view