Possible Duplicate:
Parse XML sequentially in PHP
I want to be able to iterate through a SimpleXMLElementObject using PHP. However, I want to be able to do it without knowing the tag names in advance - I want a general solution that can be used as a discovery mechanism for the object's key names. I've tried a bunch of 'foreach' type solutions but can't get it to work.
Example code:
$schema = new SimpleXMLElement("<activity></activity>");
$schema->addAttribute("default-currency","asdf");
$schema->addAttribute("last-updated-datetime","jkl;");
$schema->addChild('title', 'example title');
print_r($schema) gives:
SimpleXMLElement Object (
[@attributes] => Array (
[default-currency] => asdf
[last- updated-datetime] => jkl;
)
[title] => example title
)
Thanks