|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2001-08-26 04:53 UTC] joey@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Nov 03 14:00:01 2025 UTC |
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"; ?>