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
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:
MUST BE VALID
Solve the problem:
37 - 27 = ?
Subscribe to this entry?

 
 [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-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 12:01:28 2024 UTC