/** * @return array */ public function toArray() { $array = array(); $this->didRewind || $this->rewind(); if (!$this->valid()) { return array(); } $this->ensureCurrentElementState(); while ($this->valid()) { $element = new XMLReaderNode($this->reader); if ($this->reader->hasValue) { $string = $this->reader->value; } else { $string = $element->readString(); } if ($this->name) { $array[] = $string; } else { $array[$element->name] = $string; } $this->moveToNextElementByName($this->name); } return $array; }