Skip to content

Instantly share code, notes, and snippets.

@hakre
Created October 31, 2013 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save hakre/7250598 to your computer and use it in GitHub Desktop.
Save hakre/7250598 to your computer and use it in GitHub Desktop.
RecursiveSimpleXMLIterator
<?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