lundi 25 mars 2019

How to get value in xml using getElementByTagName in Laravel 5.7

I want to get error value from an xml. I am using Laravel 5.7 to get this. I have tried it but i don't get what i want.

This is my xml error message :

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
  <SOAP-ENV:Body>
  <SOAP-ENV:Fault>
     <faultcode>SOAP-ENV:Client</faultcode>
     <faultstring>Client Error</faultstring>
     <detail>
        <ResponseStatus>F</ResponseStatus>
        <ResponseCode>000</ResponseCode>
        <ResponseText>Error while executing the request:
    ApplicationError: (Server Message)
Category: 9
Number: 261
Call Sequence: 
Program Name: 
Text: Characteristic Type MCMX Characteristic Value BRACET combination, not found
Description: To solve the problem, check if the fields are populated, or the combination of them is a valid one to find an item in a table.
        </ResponseText>
     </detail>
  </SOAP-ENV:Fault>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

I want to get value error in tag name <ResponseText> => Text. I have tried it like my code below :

$res = $response->getBody()->getContents();
$doc = new \DOMDocument();
$doc->loadXML($res);
$status = $doc->getElementsByTagName('ResponseText');
print_r($status);

I got print_r result like this :

DOMNodeList Object
(
    [length] => 0
)

How to fix my problem?



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2UWe0w2
via IFTTT

Aucun commentaire:

Enregistrer un commentaire