3v4l.org

run code in 300+ PHP versions simultaneously
<?php $xmlresponse = '<?xml version="1.0" encoding="utf-8"?> <string xmlns="http://www.cebroker.com/CEBrokerWebService/">&lt;licensees&gt;&lt;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" /&gt;&lt;/licensees&gt;</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
Output for 7.4.0 - 7.4.32, 8.0.1 - 8.0.24, 8.1.0 - 8.1.11
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" } } }

preferences:
37.84 ms | 412 KiB | 5 Q