/** * @param array $array * * @return bool|mixed * @author Panagiotis Vagenas <*****@*****.**> * @since 150213 */ public function parseArray(array $array) { // init simple xml if is not initialized already if (!$this->simpleXML) { $this->initSimpleXML(); } // get products node $products = $this->simpleXML->children(); // parse array foreach ($array as $k => $v) { $validated = $this->validateArrayKeys($v); if (empty($validated)) { unset($array[$k]); } else { /* @var SimpleXMLExtended $product */ $product = $products->addChild($this->productElemName); foreach ($validated as $key => $value) { if ($this->isValidXmlName($value)) { $product->addChild($key, $value); } else { $product->{$key} = null; $product->{$key}->addCData($value); } } } } return $this->saveXML(); }