php - Using Guzzle to fetch xml simple_xml_load returns strange result - large file -
$res = $client->get( 'https://****', ['auth' => ['****', '****']] ); $statuscode = $res->getstatuscode(); // check res successful. if ($statuscode >= 200 && $statuscode < 300) { $xml = $res->xml(); //save feed file $xml->asxml('myfile.xml'); } //load contents of file again $xml = simplexml_load_file('myfile.xml');
file has xml in , 6mb
pretty print r prints out only
simplexmlelement object ( [@attributes] => array ( [generation-date] => 2015-03-16t23:56:26.972+01:00 [error-occurred] => false ) )
any idea problem is? $xml->children() nothing.
the problem didn't include namespace when looped through
e.g. doing
foreach ($xml->children() $item){ //... }
but needed do
foreach ($xml->children('namespace-url-info-here') $item){ //... }
the namespace info in root element of xml.
Comments
Post a Comment