使用 Guzzle 获取 xml simple_xml_load返回奇怪的结果 - 大文件


Using Guzzle to fetch xml simple_xml_load returns strange result - large file

    $res = $client->get( 'https://****', ['auth' =>  ['****', '****']] );
$statusCode = $res->getStatusCode();
// Check that the res is successful.
if ($statusCode >= 200 && $statusCode < 300)
 {
  $xml = $res->xml();
  //save the feed as a file
  $xml->asXML('myfile.xml');
 }
//load the contents of the file again 
$xml = simplexml_load_file('myfile.xml');

文件肯定有XML,大约6MB

漂亮的打印R打印出这个

SimpleXMLElement Object
(
    [@attributes] => Array
        (
            [generation-date] => 2015-03-16T23:56:26.972+01:00
            [error-occurred] => false
        )
)

知道问题是什么吗?$xml->children(( 什么都不做。

问题是我在循环访问时没有包含命名空间

例如我在做

foreach ($xml->children() as $item){
//...
}

但需要做

foreach ($xml->children('namespace-url-info-here') as $item){
//...
}

命名空间信息位于 xml 的根元素中。