    function setXML($xml_string)
    {
        $this->xml = $xml_string;
        $this->doc = new DOMDocument;

        if (!$this->doc) {
            return false;
        }

        // disable external entities and libxml errors
        $loader = libxml_disable_entity_loader(true);
        $errors = libxml_use_internal_errors(true);
        $parse_result = @$this->doc->loadXML($xml_string);
        libxml_disable_entity_loader($loader);
        libxml_use_internal_errors($errors);

        if (!$parse_result) {
            return false;
        }

        $this->xpath = new DOMXPath($this->doc);

        if ($this->xpath) {
            return true;
        } else {
            return false;
        }
    }