PHP - SimpleXML does not return an object

I was pretty stuck here when SimpleXML returned an object when I parsed it as part of an array of objects.

$a = '<?xml version="1.0" encoding="ISO-8859-1"?><BroadsoftDocument protocol="OCI" xmlns="C" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><sessionId xmlns="">1145869290</sessionId><command echo="" xsi:type="UserCallForwardingAlwaysGetResponse" xmlns=""><isActive>false</isActive><forwardToPhoneNumber>43</forwardToPhoneNumber><isRingSplashActive>false</isRingSplashActive></command></BroadsoftDocument>'; $resultA = simplexml_load_string($a); var_dump($resultA); $b = $this->_request->_response->_body; // This is the same content as $a and is a string. $resultB = simplexml_load_string($b); var_dump($resultB); 

Output $resultA is a warning object:

Warning: simplexml_load_string (): namespace warning: xmlns: C URI is not absolute in /var/www/html/Broadworks.php on line 103

The output of $resultB is an empty object?

Both $a and $b are the same string.

+3
source share
1 answer

remove xmlns="C" from your xml string

0
source

Source: https://habr.com/ru/post/1410935/


All Articles