note 103993 modified in xmlreader.read by danbrown

From: Date: Mon, 16 May 2011 15:18:31 +0000
Subject: note 103993 modified in xmlreader.read by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-179756@lists.php.net to get a copy of this message
A very simple way to avoid typing $reader->read() multiple times when you want to skip some nodes: <?php class smartXMLReader extends XMLReader { public function readTimes($count) { $i = 0; while($i < $count){ $this->read(); $i++; } } } ?> Using this smartXMLReader, <?php $reader->readTimes(3); ?> is equivalent to <?php $reader->read(); $reader->read(); $reader->read(); ?> Makes getting around in your XML document a bit easier :) --was-- A very simple way to avoid typing $reader->read() multiple times when you want to skip some nodes: class smartXMLReader extends XMLReader { public function readTimes($count) { $i = 0; while($i < $count){ $this->read(); $i++; } } } Using this smartXMLReader, $reader->readTimes(3); is equivalent to $reader->read(); $reader->read(); $reader->read(); Makes getting around in your XML document a bit easier :) http://php.net/manual/en/xmlreader.read.php

« previous php.notes (#179756) next »