Bug #74629 [Opn->Csd]: isEmptyElement returns false instead of true

From: Date: Mon, 22 May 2017 12:00:28 +0000
Subject: Bug #74629 [Opn->Csd]: isEmptyElement returns false instead of true
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-209220@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 User updated by: the_djmaze at hotmail dot com Reported by: the_djmaze at hotmail dot com Summary: isEmptyElement returns false instead of true -Status: Open +Status: Closed Type: Bug Package: XML Reader Operating System: GNU/Linux PHP Version: 7.1.5 Block user comment: N Private report: N New Comment: Never mind, the property name is misleading. It works when going back using $reader->moveToElement() after reading the attributes Previous Comments: ------------------------------------------------------------------------ [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

« previous php.bugs (#209220) next »