Bug #74629 [Csd->Nab]: isEmptyElement returns false instead of true
| From: | requinix@php.net | Date: | Mon, 22 May 2017 14:01:37 +0000 |
| Subject: | Bug #74629 [Csd->Nab]: isEmptyElement returns false instead of true | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-209226@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=74629&edit=1
ID: 74629
Updated by: requinix@php.net
Reported by: the_djmaze at hotmail dot com
Summary: isEmptyElement returns false instead of true
-Status: Closed
+Status: Not a bug
Type: Bug
Package: XML Reader
Operating System: GNU/Linux
PHP Version: 7.1.5
Block user comment: N
Private report: N
Previous Comments:
------------------------------------------------------------------------
[2017-05-22 12:00:27] the_djmaze at hotmail dot com
Never mind, the property name is misleading.
It works when going back using $reader->moveToElement() after reading the attributes
------------------------------------------------------------------------
[2017-05-22 11:46:32] the_djmaze at hotmail dot com
Description:
------------
When an empty element has attributes and you loop through them, the isEmptyElement changes from
false to true.
Test script:
---------------
<?php
$reader = new XMLReader();
$reader->xml('<?xml version="1.0"?><tr xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<td xsi:nil="true"/><td/>
</tr>', null, LIBXML_COMPACT);
while ($reader->read()) {
switch ($reader->nodeType)
{
case XMLReader::ELEMENT:
echo "{$reader->name}: " . ($reader->isEmptyElement ? 'empty element' :
'has data');
$attributes = array();
if ($reader->hasAttributes) {
while ($reader->moveToNextAttribute()) {
$attributes[$reader->localName] = $reader->value;
}
}
echo ($reader->isEmptyElement ? ' = empty element' : ' = has data') .
"\n";
break;
case XMLReader::END_ELEMENT:
echo "/{$reader->name}\n";
}
}
Expected result:
----------------
isEmptyElement = true
Actual result:
--------------
isEmptyElement = false
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=74629&edit=1