How to loop through a SimpleXMLElement object? This is what I have: I tried in many ways to iterate, but no success:
Array
(
[status] => 1
[data_nilai_siswa] => SimpleXMLElement Object
(
[item] => Array
(
[0] => SimpleXMLElement Object
(
[id_siswa] => 1
[nama_siswa] => 1
[n_bahasa] => 1.00
[n_matematika] => 1.00
[n_binggris] => 1.00
)
[1] => SimpleXMLElement Object
(
[id_siswa] => 2
[nama_siswa] => 2
[n_bahasa] => 2.00
[n_matematika] => 2.00
[n_binggris] => 2.00
)
)
)
)
i use library rest client philsturgeon/codeigniter-restclient and script rest client:
$xmlResponse = $this->rest->get('http://ift.tt/1oxbaFa');
$projects = array();
foreach($xmlResponse->project as $project) {
$projects[$project->id_siswa] = $project->nama_siswa;
echo 'Project ' . $project->nama_siswa . ' has ID ' . $project->id_siswa . PHP_EOL;
}
i get the error Message: Trying to get property of non-object? how to fix?
No comments:
Post a Comment