In the clearAttributes method, the variable
$iNodeAttributes is initialized with an empty array,
but the attributes are stored in $this->iNodeAttributes
, so they are not removed after element, but are added
up over all the elements parsed so far.
Fix: change the line to
$this->iNodeAttributes = array();
and the problem is gone.