3

I'm pretty stuck here on getting SimpleXML to return an object when I parse it a string that's part of an objects array.

$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);

The output of $resultA is an object with warning:

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

The output of $resultB is a empty object?

Both $a and $b are the same strings.

hakre
  • 193,403
  • 52
  • 435
  • 836
Luke B
  • 2,261
  • 3
  • 18
  • 15

1 Answers1

0

remove xmlns="C" from your xml string

k102
  • 7,861
  • 7
  • 49
  • 69