Created
October 31, 2013 14:19
-
-
Save hakre/7250598 to your computer and use it in GitHub Desktop.
RecursiveSimpleXMLIterator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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