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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
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

Pull Requests

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: Fri Dec 27 12:01:29 2024 UTC