Element Countable - ThomasWeinert/FluentDOM GitHub Wiki
FluentDOM\Element
implements the Countable interface. It returns the count of child nodes, or in other words $this->childNodes->length
. Be aware that this
will return whitespace nodes, too.
$xml = <<<'XML'
<items>
<item></item>
<item></item>
<item></item>
</items>
XML;
require_once(__DIR__.'/../../vendor/autoload.php');
$document = new FluentDOM\DOM\Document();
$document->preserveWhiteSpace = FALSE;
$document->loadXML($xml);
var_dump(count($document->documentElement));
int(3)