Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:12458 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 45274 invoked by uid 1010); 29 Aug 2004 10:28:11 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 45212 invoked from network); 29 Aug 2004 10:28:11 -0000 Received: from unknown (HELO jan.prima.de) (83.97.50.139) by pb1.pair.com with SMTP; 29 Aug 2004 10:28:11 -0000 Received: from BAUMBART (p508EB7AA.dip.t-dialin.net [::ffff:80.142.183.170]) (IDENT: HydraIRC, AUTH: LOGIN tobi) by jan.prima.de with esmtp; Sun, 29 Aug 2004 10:28:09 +0000 Date: Sun, 29 Aug 2004 12:30:18 +0200 Reply-To: Marcus Boerger X-Priority: 3 (Normal) Message-ID: <24016851.20040829123018@marcus-boerger.de> To: Mathieu Bruneau CC: internals@lists.php.net In-Reply-To: <41313CF1.3000706@argontechnologies.ca> References: <41313CF1.3000706@argontechnologies.ca> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: 7bit X-Mime-Autoconverted: from 8bit to 7bit by courier 0.43 Subject: Re: [PHP-DEV] SimpleXMLIterator From: helly@php.net (Marcus Boerger) Hello Mathieu, Sunday, August 29, 2004, 4:18:25 AM, you wrote: > Hi all, > I have been playing with the SPL lately and today I ended up playing > with the SimpleXMLIterator. > The documentation on that class if fairly poor and I'm in fact > requesting some information about it. I managed to create a > SimpleXMLIterator passing it basic xml in the constructor but wasn't > able to get anything from the getChildren() method and hasChildren() > return false. The var_dump of the iterator show me the expected thing tough. > Nor does the current() or key() return anything. I'm using php5.0.1 > Example: > $xml = "Here we areThere"; > $it = new SimpleXMLIterator($xml); > var_dump($it); > while($it->hasChildren()) > { > echo "While\n"; > $child = $it->getChildren(); > } Try working with while($it->valid().... Besides that SimpleXMLIterator implements the RecursiveIterator interface. What it does is iterating over one element and if teh element has sub elements then hasChildren() returns true and getchildren() returns the iterator for that sub element. To see what's going on have a look at ext/spl/tests/sxe_00*.phpt. regards marcus