Iteration

The XMLReader instance acts as both an iterator over the entire document as well as a data object for the current node pointed to by that iterator.    It contains a set of read-only properties (described at

http://php.net/manual/en/class.xmlreader.php#xmlreader.props) that represent those of the current node and are updated as the iterator position changes.

<?php
while ($doc->read()) {
}
?>

The read() method attempts to move the iterator position to the next node and returns a boolean value indicating whether or not it was successful. That is, it returns false once it reaches the end of the document. As such, it’s perfect for use in a while loop as shown above.

 


© XMLReader Extension — Web Scraping

>>> Back to TABLE OF CONTENTS <<<
Category: Article | Added by: Marsipan (03.09.2014)
Views: 310 | Rating: 0.0/0
Total comments: 0
avatar