<?php
$xmlresponse = '<?xml version="1.0" encoding="utf-8"?>
<string xmlns="http://www.cebroker.com/CEBrokerWebService/"><licensees><licensee
valid="true" State="FL" licensee_profession="RN"
licensee_number="2676612" state_license_format="" first_name="HENRY"
last_name="GEITER" ErrorCode="" Message="" TimeStamp="2/19/2022
4:53:35 AM" /></licensees></string>';
$xml_string = simplexml_load_string($xmlresponse);
echo 'First time, we only get it as a string, not as XML' . PHP_EOL;
echo '------------------------------------------'. PHP_EOL;
var_dump($xml_string); // We can see that it's just a stirng, not XML
echo PHP_EOL . PHP_EOL;
$licensees = simplexml_load_string($xml_string);
echo 'The second time, we do get it as XML' . PHP_EOL;
echo '------------------------------------------'. PHP_EOL;
var_dump($licensees); // Not it's actually read as XML
First time, we only get it as a string, not as XML
------------------------------------------
object(SimpleXMLElement)#1 (1) {
[0]=>
string(233) "<licensees><licensee
valid="true" State="FL" licensee_profession="RN"
licensee_number="2676612" state_license_format="" first_name="HENRY"
last_name="GEITER" ErrorCode="" Message="" TimeStamp="2/19/2022
4:53:35 AM" /></licensees>"
}
The second time, we do get it as XML
------------------------------------------
object(SimpleXMLElement)#2 (1) {
["licensee"]=>
object(SimpleXMLElement)#3 (1) {
["@attributes"]=>
array(10) {
["valid"]=>
string(4) "true"
["State"]=>
string(2) "FL"
["licensee_profession"]=>
string(2) "RN"
["licensee_number"]=>
string(7) "2676612"
["state_license_format"]=>
string(0) ""
["first_name"]=>
string(5) "HENRY"
["last_name"]=>
string(6) "GEITER"
["ErrorCode"]=>
string(0) ""
["Message"]=>
string(0) ""
["TimeStamp"]=>
string(21) "2/19/2022 4:53:35 AM"
}
}
}