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
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: 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

Add a Patch

Pull Requests

Add a Pull Request

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-2022 The PHP Group
All rights reserved.
Last updated: Thu Jan 27 01:03:35 2022 UTC