/** * Transform an associative array or associative iterable to a xml document. * @param mixed $iterable * @param DOMElement $element * @param DOMDocument $document * @return void */ public function assocToXml($iterable, DOMElement $element, DOMDocument $document) { foreach ($iterable as $key => $item) { $iterable = is_array($item) || $item instanceof Iterator; if ($iterable && ArrayUtil::isIndexed($item)) { $key = StringUtil::pluralize($key); } if (is_int($key)) { $key = $this->numNodePrefix . $key; } $node = $document->createElement($key); $element->appendChild($node); $this->toXml($item, $node, $document); } }