PHP xmlSOAP格式 转换为数组

xiaoxiao2022-07-06  8


某平台价值19860元的编程课程资料免费领取【点我领取】


$xml='<?xml version="1.0" encoding="utf-8"?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"> <SOAP-ENV:Header/> <SOAP-ENV:Body> <Parameters xmlns="http://hl7.org/fhir" xmlns:sin="http://register.lfwsj.gov.cn/sinosoft_register"> <parameter> <name value="success"/> <valueString value="false"/> </parameter> <parameter> <name value="stateCode"/> <valueString value="705"/> </parameter> <parameter> <name value="stateInfo"/> <valueString value="123456789"/> </parameter> </Parameters> </SOAP-ENV:Body> </SOAP-ENV:Envelope> '; $xmlObj = simplexml_load_string($xml); $xmlObj->registerXPathNamespace('soap', 'http://schemas.xmlsoap.org/soap/envelope/'); $result = $xmlObj->xpath("soap:Body"); $results = object_to_array($result); /** * 对象 转 数组 * * @param object $obj 对象 * @return array */ function object_to_array($obj) { $obj = (array)$obj; foreach ($obj as $k => $v) { if (gettype($v) == 'resource') { return; } if (gettype($v) == 'object' || gettype($v) == 'array') { $obj[$k] = (array)object_to_array($v); } } return $obj; }

 

转载请注明原文地址: https://www.6miu.com/read-4968555.html

最新回复(0)