public function buildXML(array $data, $startElement = 'data')
    {
        if (!\is_array($data)) {
            $err = 'Invalid variable type supplied, expected array not found on line ' . __LINE__ . ' in Class: ' . __CLASS__ . ' Method: ' . __METHOD__;
            \trigger_error($err);
            return false; //return false error occurred
        }
        $xml = new \XmlWriter();
        $xml->openMemory();
        $xml->startDocument($this->version, $this->encoding);
        $xml->startElement($startElement);

        $data = $this->writeAttr($xml, $data);
        $this->writeEl($xml, $data);

        $xml->endElement(); //write end element
        //returns the XML results
        return $xml->outputMemory(true);
    }