将特定的 XML 转换为 PHP 数组

时间:2021-02-26 15:11:02

标签: php xml

我正在尝试将此特定 XML 文件转换为 PHP 数组

http://www.crcind.com/csp/samples/SOAP.Demo.cls?soap_method=QueryByName&name=John

我想得到的部分是

<QueryByName diffgr:id="QueryByName1"msdata:rowOrder="0"><ID>174</ID><Name>Johnson,Brian T.</Name><DOB>1934-11-09</DOB><SSN>751-82-3888</SSN></QueryByName>  

我尝试使用soapResponseToJson(xml) 还有

    $xmlfile = file_get_contents($path);

//convert xml string into an object
$xml = simplexml_load_string($xmlfile);

//convert into json
$json  = json_encode($xml);

//convert into associative array
$xmlArr = json_decode($json, true);

但一直不工作。

你能帮我吗?
亲切的问候。

0 个答案:

没有答案
相关问题