|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #43392 problem with xml comments
Submitted: 2007-11-23 19:16 UTC Modified: 2007-11-28 13:41 UTC
Avg. Score:4.5 ± 0.5
Reproduced:2 of 2 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (50.0%)
From: 007NOT at gmail dot com Assigned:
Status: Not a bug Package: SimpleXML related
PHP Version: 5.2.5 OS: win xp sp2
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.
Block user comment
Status: Assign to:
Bug Type:
From: 007NOT at gmail dot com
New email:
PHP Version: OS:


 [2007-11-23 19:16 UTC] 007NOT at gmail dot com
simpleXml makes counteble xml comments. see code:

Reproduce code:
$string = <<<XML
<?xml version='1.0'?> 
 <node><!-- comment --></node>
$xml = simplexml_load_string($string);
echo "Node: ". count((array) $xml->node) . "\n";            //expects 0
echo "Other Node: ".count((array) $xml->otherNode) . "\n";  //expects 1

Expected result:
Node: 0
Other Node: 0

Actual result:
Node: 1
Other Node: 0


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2007-11-28 13:41 UTC]
This is just normal and expected behaviour. 

<foo><!-- comment --></foo> is not same as <foo></foo>.

(try var_dump($xml); to see what happens)

PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Tue Jun 06 22:03:38 2023 UTC