Re: SimpleXMLIterator methods
| From: | Philip Fletcher | Date: | Thu, 11 Mar 2004 12:03:55 +0000 |
| Subject: | Re: SimpleXMLIterator methods | ||
| References: | 1 | Groups: | php.xml.dev |
| Request: | Send a blank email to php-xml-dev+get-351@lists.php.net to get a copy of this message | ||
I finally found the answer to my own question (although re-reading, I see I
have the hierarchy wrong, which is why it didn't work as I expected).
If you want to treat a simplexml object as an iterator, then you have to
call simplexml_load_[file|string] with an (as yet) undocumented second
parameter: 'SimpleXMLIterator'
e.g. $sxi = simplexml_load_file('mydata.xml', 'SimpleXMLIterator');
I found this in the ext/spl/tests/sxe_003.phpt file.
Philip
P.S. Is there anyway to get PHPDoc/JavaDoc style API documentation out of
the ext/xxx classes? (rather than my somewhat dodgy attempts to understand
the source:)
Philip Fletcher wrote:
> If simplexml_element implements SimpleXmlIterator which implements
> RecursiveIterator which implements Iterator, should I not be able to
> access the rewind(), current(), key(), next() and hasMore() methods on a
> given simplexml_element?
>
> Regards
>
> Philip