Bug #70029 [Opn->Ver]: nodeValue of DOMElement list content of children nodes
| From: | cmb@php.net | Date: | Wed, 08 Jul 2015 21:21:06 +0000 |
| Subject: | Bug #70029 [Opn->Ver]: nodeValue of DOMElement list content of children nodes | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-194230@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=70029&edit=1
ID: 70029
Updated by: cmb@php.net
Reported by: Laurent dot Lyaudet at gmail dot com
Summary: nodeValue of DOMElement list content of children
nodes
-Status: Open
+Status: Verified
Type: Bug
Package: DOM XML related
Operating System: Debian Linux
PHP Version: 5.4.42
Block user comment: N
Private report: N
New Comment:
Confirmed: <http://3v4l.org/nrYAR>.
According to the "Document Object Model Core" specification[1]
nodeValue is supposed to yield null for Element nodes, so the
behavior may be considered as bug. However, it works this way
since the beginnings of the DOM extension, and the
documentation[2] isn't particularly clear with regard to the exact
behavior, so changing the behavior would introduce a BC break
which is not easily noticed.
Nonetheless, this should be fixed for PHP 7 (even though beta1 has
already been tagged, which marks the feature freeze), in my
opinion.
[1] <http://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-F68D080>
[2] <http://de2.php.net/manual/en/class.domnode.php#domnode.props.nodevalue>
Previous Comments:
------------------------------------------------------------------------
[2015-07-08 20:57:46] Laurent dot Lyaudet at gmail dot com
Description:
------------
Hi,
When using nodeValue attribute of a DOMElement, the content of descendant (children, grandchildren,
etc.) nodes of the DOMElement are listed.
This bug emerged from a discussion on bug 65569
https://bugs.php.net/bug.php?id=65569
Best regards,
Laurent Lyaudet
Test script:
---------------
<?php
$xml = new DOMDocument();
$xml->loadXml('<tag><childtag>myString</childtag></tag>');
echo $xml->documentElement->nodeValue, "\n";
?>
or
<?php
$xml = new DOMDocument();
$xml->loadXml('<tag><childtag><grandchildtag>myString</grandchildtag></childtag></tag>');
echo $xml->documentElement->nodeValue, "\n";
?>
Expected result:
----------------
no output
Actual result:
--------------
myString
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=70029&edit=1