Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save jesramirez/8659623 to your computer and use it in GitHub Desktop.

Select an option

Save jesramirez/8659623 to your computer and use it in GitHub Desktop.
<?php
/**
* Class RecursiveSimpleXMLIterator
*
* RecursiveIterator for SimpleXMLElement
*/
class RecursiveSimpleXMLIterator extends IteratorIterator implements RecursiveIterator
{
function __construct(SimpleXMLElement $xml) {
parent::__construct($xml);
}
public function hasChildren()
{
return (bool) $this->current();
}
public function getChildren()
{
return new self($this->current());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment