api/MarkLogic/MLPHP/Options.php
public function getAsXML()
    {
        // root
        $this->dom = new \DOMDocument(); // reset so we don't continually to add to the options node
        $root = $this->dom->createElement('options');
        $root->setAttribute('xmlns', 'http://marklogic.com/appservices/search');
        $this->dom->appendChild($root);

        // constraints
        foreach ($this->constraints as $constraint) {
            $root->appendChild($constraint->getAsElem($this->dom));
        }

        // values
        foreach ($this->values as $value) {
            $root->appendChild($value->getValuesAsElem($this->dom));
        }

        // metadata extracts
        if(isset($this->extracts)) {
            $extractsElem = $this->extracts->getExtractsAsElem($this->dom);
            $root->appendChild($extractsElem);
        }

        // transform results (snippetting)
        if(isset($this->transformResults)) {
            $transElem = $this->transformResults->getTransformResultsAsElem($this->dom);
            $root->appendChild($transElem);
        }

        // term
        if(isset($this->term)) {
            $termElem = $this->term->getAsElem($this->dom);
            $root->appendChild($termElem);
        }

        $this->addOptionXML($root, 'additional-query', $this->additionalQuery);
        $this->addOption($root, 'concurrency-level', $this->concurrencyLevel);
        $this->addOption($root, 'debug', $this->debug);
        $this->addOption($root, 'forest', $this->forest);
        $this->addOption($root, 'page-length', $this->pageLength);
        $this->addOption($root, 'quality-weight', $this->qualityWeight);
        $this->addOption($root, 'return-constraints', $this->returnConstraints);
        $this->addOption($root, 'return-facets', $this->returnFacets);
        $this->addOption($root, 'return-metrics', $this->returnMetrics);
        $this->addOption($root, 'return-plan', $this->returnPlan);
        $this->addOption($root, 'return-qtext', $this->returnQtext);
        $this->addOption($root, 'return-query', $this->returnQuery);
        $this->addOption($root, 'return-results', $this->returnResults);
        $this->addOption($root, 'return-similar', $this->returnSimilar);
        if (!empty($this->searchOptions)) {
            foreach($this->searchOptions as $opt) {
                $this->addOption($root, 'search-option', $this->returnSimilar);
            }
        }
        return $this->dom->saveXML();
    }
public function getAsXML()
    {
        // root
        $this->dom = new \DOMDocument(); // reset so we don't continually to add to the options node
        $root = $this->dom->createElement('options');
        $root->setAttribute('xmlns', 'http://marklogic.com/appservices/search');
        $this->dom->appendChild($root);

        // constraints
        foreach ($this->constraints as $constraint) {
            $root->appendChild($constraint->getAsElem($this->dom));
        }

        // values
        foreach ($this->values as $value) {
            $root->appendChild($value->getValuesAsElem($this->dom));
        }

        // metadata extracts
        if(isset($this->extracts)) {
            $extractsElem = $this->extracts->getExtractsAsElem($this->dom);
            $root->appendChild($extractsElem);
        }

        // transform results (snippetting)
        if(isset($this->transformResults)) {
            $transElem = $this->transformResults->getTransformResultsAsElem($this->dom);
            $root->appendChild($transElem);
        }

        // term
        if(isset($this->term)) {
            $termElem = $this->term->getAsElem($this->dom);
            $root->appendChild($termElem);
        }

        $this->addOptionXML($root, 'additional-query', $this->additionalQuery);
        $this->addOption($root, 'concurrency-level', $this->concurrencyLevel);
        $this->addOption($root, 'debug', $this->debug);
        $this->addOption($root, 'forest', $this->forest);
        $this->addOption($root, 'page-length', $this->pageLength);
        $this->addOption($root, 'quality-weight', $this->qualityWeight);
        $this->addOption($root, 'return-constraints', $this->returnConstraints);
        $this->addOption($root, 'return-facets', $this->returnFacets);
        $this->addOption($root, 'return-metrics', $this->returnMetrics);
        $this->addOption($root, 'return-plan', $this->returnPlan);
        $this->addOption($root, 'return-qtext', $this->returnQtext);
        $this->addOption($root, 'return-query', $this->returnQuery);
        $this->addOption($root, 'return-results', $this->returnResults);
        $this->addOption($root, 'return-similar', $this->returnSimilar);
        if (!empty($this->searchOptions)) {
            foreach($this->searchOptions as $opt) {
                $this->addOption($root, 'search-option', $this->returnSimilar);
            }
        }
        return $this->dom->saveXML();
    }
Get the query options as XML.

@return string The query options as XML.