Hello.
I create xml file with structure
<?xml version="1.0" encoding="utf-8"?> <parent> <son>Tolya</son> <big>Sash ...... <year>1999</year> ..... <fu> future <date>dates</date> </fu> </big> </parent>
Now there is a php file
$xml=simplexml_load_file('info.xml');
I want to access the property values of the $ xml object. You can access the son, but I don’t know how to year (it can be nested in a couple of elements) if the file structure is not known . Help with the function of traversing all properties of the object. I tried to create such a function to bypass all the elements.
function recurse($obj){ foreach($obj as $k=>$v){ if(is_object($k)) {recurse($k);} else{ echo $k; } } } recurse($xml);
but failed.