I am trying to read a XML file from the URL, with the help of XMLReader Iterators https://gist.github.com/hakre/5147685
$reader = new XMLReader();
$reader->open($filename);
$element = new XMLReaderNode($reader);
$it = new XMLElementIterator($reader, 'coupon');
$data = array();
$i = 0;
foreach($it as $index => $element) {
if( $i == 0 ) {
$xml = $element->asSimpleXML();
//print_r($xml->children());
foreach( $xml as $k=>$v ) {
$data[0][strtolower("{$k}")] = "{$v}";
}
}// End IF
}
print_r($data);
Its working fine with the small file, but its taking long time to read xml file from url.
Can i first download the file from url then READ it?
Is it the right way that i am doing?
Is there any other alternative?