diff --git a/service/Application/Library/AlipayLife.class.php b/service/Application/Library/AlipayLife.class.php index f796ca1a7..98ec1a6b3 100644 --- a/service/Application/Library/AlipayLife.class.php +++ b/service/Application/Library/AlipayLife.class.php @@ -34,7 +34,7 @@ class AlipayLife public function __construct($params = []) { $this->params = $params; - $this->xml_data = isset($params['biz_content']) ? $this->xmlToArraywww($params['biz_content']) : ''; + $this->xml_data = isset($params['biz_content']) ? $this->parseXml($params['biz_content']) : ''; //$this->xml_data = json_decode(json_encode((array) simplexml_load_string($params['biz_content'])), true); file_put_contents('./pppppp.php', "xml_data, true).";\n\r?>"); @@ -47,6 +47,26 @@ class AlipayLife } } + public function parseXml($xmls) + { + $array = []; + + foreach ($xmls as $key => $xml) { + /** @var SimpleXMLElement $xml */ + $count = $xml->count(); + + if ($count == 0) { + $res = (string) $xml; + } else { + $res = $this->parseXml($xml); + } + + $array[$key] = $res; + } + + return $array; + } + public function xmlToArraywww($xml){ //考虑到xml文档中可能会包含标签,第三个参数设置为LIBXML_NOCDATA if (file_exists($xml)) {