|  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
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:
Solve the problem:
9 + 1 = ?
Subscribe to this entry?

 [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-2022 The PHP Group
All rights reserved.
Last updated: Fri Jan 21 06:03:41 2022 UTC