protected static function xmlToDOMDocument($var, $parent_path)
    {
        // There's no way to check validity in DOMDocument without making errors. For shame!
        if (!self::xmlToSimpleXML($var, $parent_path)) {
            return null;
        }

        $xml = new DOMDocument();
        $xml->loadXML($var);
        $xml = $xml->firstChild;

        if (null === $parent_path) {
            $access_path = null;
        } else {
            $access_path = '@\\DOMDocument::loadXML('.$parent_path.')->firstChild';
        }

        $name = $xml->nodeName;

        return array($xml, $access_path, $name);
    }