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
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: joaomfrebelo at gmail dot com
New email:
PHP Version: OS:

 

 [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: Thu Apr 25 19:01:33 2024 UTC