我尝试获取从CEBroker WebServices调用返回的XML字符串,例如:
<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/18/2022 6:43:20 PM" />
</licensees>
解析字符串以获得属性值,因为它们总是相同的,并且每个字符串只有一个许可证持有者。XML字符串在$xmlresponse中返回,当我使用print_r将其打印出来时,它是正确的,但当我尝试解析时,总是什么也得不到。
我试过了
$xml_string = simplexml_load_string($xmlresponse);
print_r ("this is my xml after going through simplexml_load_string" . $xml_string);
//上面的行不打印$xml_string;
$json = json_encode($xml_string);
print_r($json);
$array = json_decode($json,TRUE);
echo "<p>Array contents are as follows</p>";
print_r($array);
var_dump ($array);
echo "<p>Array contents ended!</p>";
我是XML新手,只需要知道如何解析返回的XML数据或XML文件的节点和属性(在本例中)。
谢谢
1条答案
按热度按时间nr7wwzry1#
如果我没有理解错您的问题,请尝试以下操作,该操作假定有两个许可证持有者的响应:
输出量:
输出量