public function &buildArray($inputXml)
    {
        $this->init();

        if (is_string($inputXml)) {
            $this->xml = $this->createDOMDocument();
            $parsed = $this->xml->loadXML($inputXml);
            if ( ! $parsed) {
                throw new \Exception('[Transformer] Error parsing the XML string.');
            }
        } elseif ($inputXml instanceof \DOMDocument) {
            $this->xml = $inputXml;
        } else {
            throw new \Exception('[Transformer] The input XML object should be of type: DOMDocument but got instead ['.gettype($inputXml).'].');
        }
        
        // Convert the XML to an array, starting with the root node
        $docNodeName = $this->xml->documentElement->nodeName;
        $array[$docNodeName] = $this->convert($this->xml->documentElement);
        
        // Add namespacing information to the root node
        if ( ! empty($this->namespaces)) {
            if ( ! isset($array[$docNodeName][$this->config['attributesKey']])) {
                $array[$docNodeName][$this->config['attributesKey']] = array();
            }
            foreach ($this->namespaces as $uri => $prefix) {
                if ($prefix) {
                    $prefix = self::ATTRIBUTE_NAMESPACE_SEPARATOR . $prefix;
                }
                $array[$docNodeName][$this->config['attributesKey']][self::ATTRIBUTE_NAMESPACE . $prefix] = $uri;
            }
        }
        return $array;
    }