php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #80755 next function does not go strict to next sibling node
Submitted: 2021-02-16 11:18 UTC Modified: 2021-02-16 11:24 UTC
From: joaomfrebelo at gmail dot com Assigned: cmb (profile)
Status: Not a bug Package: XML Reader
PHP Version: Irrelevant OS: Windows 10
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
3 - 1 = ?
Subscribe to this entry?

 
 [2021-02-16 11:18 UTC] joaomfrebelo at gmail dot com
Description:
------------
When we advance the cursor with next function the cursor position should be the next sibling node, how ever wrongly the cursor goes always first to the “#text” node:

Output of the bellow test:

PHPUnit 9.5.2 by Sebastian Bergmann and contributors.

Runtime:       PHP 8.0.1
Configuration: D:\NetBeansProjects\PHP\Saft-PT_4_php_EE\phpunit.xml

Node name Should be 'Customer' and is 'Customer' 
Node name Should be 'Customer' and is '#text' 
Node name Should be 'Customer' and is 'Customer' 
Node name Should be 'Customer' and is '#text' 
Node name Should be 'Customer' and is 'Customer' 
Node name Should be 'Customer' and is '#text' 
Node name Should be 'Customer' and is 'Customer' 
Node name Should be 'Customer' and is '#text' 
Node name Should be 'Customer' and is 'MasterFiles' 


Time: 00:00.149, Memory: 6.00 MB

Test script:
---------------
public function testTest(): void
    {
        $document = <<<XML
    <MasterFiles>
        <Customer><CustomerID>CA1</CustomerID></Customer>
        <Customer><CustomerID>RES</CustomerID></Customer>
        <Customer><CustomerID>PP</CustomerID></Customer>
        <Customer><CustomerID>CA3</CustomerID></Customer>  
    </MasterFiles> 
XML;
        
        $reader = new \XMLReader();
        $reader->XML($document);
        
        while ($reader->name !== "Customer"){ $reader->read();}
        
        do{
        echo \sprintf("Node name Should be 'Customer' and is '%s' \n", $reader->name);
        }while ($reader->next());
    }

Expected result:
----------------
Node name Should be 'Customer' and is 'Customer' 
Node name Should be 'Customer' and is 'Customer'
Node name Should be 'Customer' and is 'Customer'
Node name Should be 'Customer' and is 'Customer'

Actual result:
--------------
Output of the above test:

PHPUnit 9.5.2 by Sebastian Bergmann and contributors.

Runtime:       PHP 8.0.1
Configuration: D:\NetBeansProjects\PHP\Saft-PT_4_php_EE\phpunit.xml

Node name Should be 'Customer' and is 'Customer' 
Node name Should be 'Customer' and is '#text' 
Node name Should be 'Customer' and is 'Customer' 
Node name Should be 'Customer' and is '#text' 
Node name Should be 'Customer' and is 'Customer' 
Node name Should be 'Customer' and is '#text' 
Node name Should be 'Customer' and is 'Customer' 
Node name Should be 'Customer' and is '#text' 
Node name Should be 'Customer' and is 'MasterFiles' 


Time: 00:00.149, Memory: 6.00 MB

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-02-16 11:24 UTC] cmb@php.net
-Status: Open +Status: Not a bug -Assigned To: +Assigned To: cmb
 [2021-02-16 11:24 UTC] cmb@php.net
The next siblings of all the Customer elements are text nodes
(namely the whitespace between the Customer elements).
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 05 13:01:30 2024 UTC