php.net |  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
Votes:2
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
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: 007NOT at gmail dot com
New email:
PHP Version: OS:

 

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

Reproduce code:
---------------
$string = <<<XML
<?xml version='1.0'?> 
<document>
 <node><!-- comment --></node>
 <otherNode></otherNode>
</document>
XML;
$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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-11-28 13:41 UTC] jani@php.net
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-2025 The PHP Group
All rights reserved.
Last updated: Wed Feb 05 08:01:30 2025 UTC