php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #9740 wrong xml node content
Submitted: 2001-03-14 09:54 UTC Modified: 2001-08-26 04:53 UTC
From: marcel at humanique dot com Assigned:
Status: Closed Package: DOM XML related
PHP Version: 4.0.4pl1 OS: Linux 2.2.16-3 (RH)
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: marcel at humanique dot com
New email:
PHP Version: OS:

 

 [2001-03-14 09:54 UTC] marcel at humanique dot com
Element nodes contain the wrong content

When I loop through all the children of the node "root" of the following xml then the fourth child (second <my>)contains ($node->content) "2<newline><newline>3<newline><newline>" which should be nothing since its empty.
When I examine the output of a domxml_dumpmem dump of the $xml variable it does contain the correct data.
Libxml version is 2.3.2

xml:
<?xml version="1.0"?>
<root>
<my>1</my>
<my/>
<my>2</my>
<my/>
<my>3</my>
</root>

output of my script:
idx=0 name=text content=

idx=1 name=my content=1
idx=2 name=text content=

idx=3 name=my content=
2

3

idx=4 name=text content=

idx=5 name=my content=2
idx=6 name=text content=

idx=7 name=my content=
3

idx=8 name=text content=

idx=9 name=my content=3
idx=10 name=text content=
end of output


my script:
<?php

$txt  = "<?xml version=\"1.0\"?>\n";
$txt .= "<root>\n";
$txt .= "<my>1</my>\n";
$txt .= "<my/>\n";
$txt .= "<my>2</my>\n";
$txt .= "<my/>\n";
$txt .= "<my>3</my>\n";
$txt .= "</root>\n";

$xml = xmldoc($txt);

$root = $xml->children();

$children = $root[0]->children();

echo "<pre>\n";
for($i=0; $i < count($children); $i++) {
        echo "idx=$i name=" . $children[$i]->name;
        echo " content=" . $children[$i]->content;
        echo "\n";
}
echo "</pre>\n";
?>

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-08-26 04:53 UTC] joey@php.net
Closed in CVS, fix will be part of 4.0.7.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 01:01:30 2024 UTC