<?php header("Content-Type:text/html;charset=utf-8"); function xml2array($filename){ $xml = @simplexml_load_file($filename); //返回数组 if(is_object($xml)){ $xml = json_encode($xml); $xml = json_decode($xml, true); } if(!is_array($xml)) $xml = null; return $xml; } $path = 'f.xml'; echo '<pre>'; var_dump(xml2array($path)); ?>