I want to read xml data using curl in codeigniter. I have create a helper file which will read data from following url: http://www.ekidata.jp/api/l/11302.xml but problem is that i cannot read the data from this url. plz help Here is my helper file structure:
if (!function_exists('ekidata')) {
function ekidata($type, $code)
{
$apiurl = 'http://www.ekidata.jp/api/'.$type.'/'.$code.'.xml';
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $apiurl);
$response = curl_exec($ch);
curl_close($ch);
$xml = simplexml_load_string($response);
if ($type == 'l') {
return $xml;
} else {
}
}
}
Here is my controller:
function ekidatatest()
{
$this->load->view('ekidatatest');
}
Here is my view:
<?php echo ekidata('l', 11302);?>