PHP xml SOAP格式 转换为数组

$xml='


  
  
    
      
        
        
      
      
        
        
      
      
        
        
      
    
  

';
$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;
}
	

 

你可能感兴趣的:(PHP,PHP,xml,SOAP)