Doc #64470 [NEW]: XMLReader::next($localname) moves cursor even if there is no more $localname
From: halil dot ozgur at gmail dot com
Operating system: Irrelevant
PHP version: Irrelevant
Package: Documentation problem
Bug Type: Documentation Problem
Bug description:XMLReader::next($localname) moves cursor even if there is no more $localname
Description:
------------
---
From manual page: http://www.php.net/xmlreader.next
---
I'm not sure if this obvious, or is not a bug. next() method when invoked
with a
parameter (with $localname non-empty) moves the cursor even if there is no
more
$localname items and next() returns false. This in fact proved helpful for
me
while implementing a custom iterator. But it could still be useful to
include this
information in the documentation.
Test script:
---------------
<?php
$itemTag = "test";
$xml = <<<EOX
<?xml version="1.0" encoding="utf-8"?>
<tests>
<test>
<lorem>11111</lorem>
</test>
<test>
<lorem>22222</lorem>
</test>
</tests>
EOX;
$reader = new \XMLReader();
$reader->XML($xml);
// move to the first element
while ($reader->read() && $reader->name !== $itemTag) {}
echo "Current: " . $reader->name . "\n";
$reader->next($itemTag);
$reader->next($itemTag);
echo "Current: " . $reader->name . "\n";
Expected result:
----------------
Current: test
Current: test
Actual result:
--------------
Current: test
Current:
--
Edit bug report at https://bugs.php.net/bug.php?id=64470&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=64470&r=trysnapshot54
Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=64470&r=trysnapshot53
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=64470&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=64470&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=64470&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=64470&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=64470&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=64470&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=64470&r=support
Expected behavior: https://bugs.php.net/fix.php?id=64470&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=64470&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=64470&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=64470&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=64470&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=64470&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=64470&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=64470&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=64470&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=64470&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=64470&r=mysqlcfg
Thread (3 messages)
- halil dot ozgur at gmail dot com