In simplexml, accessing elements returns SimpleXMLElement objects. You can view the contents of these objects with var_dump.
$book=simplexml_load_string('<page id="id1"><content name="abc">def</content></page>');
$content=$book->content;
var_dump($content);
You can access these objects using the foreach loop.
foreach($obj as $value) {
if (is_array($value)) {
foreach ($value as $name=>$value) {
print $name.": ".$value."\n";}
}
else print $value;
}
You can not only extract content (for example, elements and attributes), but also add and delete them. You can also use Xpath to move values into a complex XML tree. You just need to go through the class of the SimpleXMLElement class here .
source
share