Edit report at https://bugs.php.net/bug.php?id=65569&edit=1
ID: 65569
Updated by: mike@php.net
Reported by: Laurent dot Lyaudet at gmail dot com
Summary: ChildNodes of DOMNodes list great childs, etc. as
DOMText
-Status: Open
+Status: Feedback
Type: Bug
Package: DOM XML related
Operating System: Debian Linux
PHP Version: 5.4.19
Block user comment: N
Private report: N
New Comment:
Not enough information was provided for us to be able
to handle this bug. Please re-read the instructions at
http://bugs.php.net/how-to-report.php
If you can provide more information, feel free to add it
to this bug and change the status back to "Open".
Thank you for your interest in PHP.
Previous Comments:
------------------------------------------------------------------------
[2013-08-28 08:55:21] Laurent dot Lyaudet at gmail dot com
My bad, it looks similar to bug 40175 but looking at the sample code for 40175 it is totally
different. 40175 use getElementsByTagName but the description says
The childNodes "function" returns a DOMNodeList (I added the quotes)
I mentally corrected to "The childNodes is a DOMNodeList" when I first looked at this
shit.
------------------------------------------------------------------------
[2013-08-28 08:45:36] Laurent dot Lyaudet at gmail dot com
Description:
------------
Hi,
When using DOMNodes and other heriting classes (DOMDocument, DOMElement, etc.),
the childNodes attribute lists real childrens as DOMElement mixed with DOMText for the content of
grandchildren.
It is similar to bug 40175 but more detailed. Moreover I don't see why the manual is cited as a
justification for bug 40175:
from http://www.php.net/manual/en/class.domnode.php
:
> childNodes>> A DOMNodeList that contains all children of this node. If there are no >children, this is
> an empty DOMNodeList.
I join a debug function to supplement the bug in var_dump (see bug 65565 : https://bugs.php.net/bug.php?id=65565&thanks=4).
function debugSousBalises($p_oBalise){
for($i = 0; $i < $p_oBalise->childNodes->length; ++$i){
$oNode = $p_oBalise->childNodes->item($i);
//var_dump($oNode);
switch(get_class($oNode)){
case 'DOMText':
echo $oNode->wholeText;
break;
case 'DOMElement':
echo $oNode->tagName.' : '.$oNode->nodeValue;
break;
default:
echo get_class($oNode).' pas encore pris en compte';
}
}
}
used on the following fragment of xml
<balise>
<ata>2013-08-20T17:13:25</ata>
<atd>2013-08-20T17:15:03</atd>
<callSequence>1</callSequence>
<actualCallSequence>2</actualCallSequence>
<clauseInfo>
<clause>LIV_CFM</clause>
<description>Conforme</description>
</clauseInfo>
</balise>
it will yield:
ata : 2013-08-20T17:13:25
atd : 2013-08-20T17:15:03
callSequence : 1
actualCallSequence : 2
clauseInfo :
LIV_CFM
Conforme
Best regards,
Laurent Lyaudet
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=65569&edit=1