Try this:
$xml_content = file_get_contents('http://url/feed.xml');
$data = simplexml_load_string($xml_content);
foreach ($data->item as $item) {
var_dump($item->bookname);
}
You can also cast whole $item to array if you need:
foreach ($data->item as $item) {
$itemArray = (array) $item;
var_dump($itemArray);
}
You were dumping objects, when you need to cast the to string first to return the text value.
Also, I do not think the second foreach
was doing anything or needed, so I removed it.