api/MarkLogic/MLPHP/Metadata.php
public function getAsXML()
    {

        // root
        $dom = new \DOMDocument();
        $root = $dom->createElement('metadata');
        $root->setAttribute('xmlns', 'http://marklogic.com/rest-api');
        $dom->appendChild($root);

        // collections
        $collElem = $dom->createElement('collections');
        foreach($this->collections as $v) {
            $collElem->appendChild($dom->createElement('collection', $v));
        }
        $root->appendChild($collElem);

        // permissions
        $permElem = $dom->createElement('permissions');
        foreach($this->permissions as $rn => $p) {
            $pElem = $dom->createElement('permission');
            $pElem->appendChild($dom->createElement('role-name', $p->getRoleName()));
            foreach($p->getCapabilities() as $c) {
                $pElem->appendChild($dom->createElement('capability', $c));
            }
            $permElem->appendChild($pElem);
        }
        $root->appendChild($permElem);

        // properties
        $propElem = $dom->createElement('prop:properties');
        $propElem->setAttribute('xmlns:prop', 'http://marklogic.com/xdmp/property');
        foreach($this->properties as $k => $v) {
            $pElem = $dom->createElement($k, $v);
            $pElem->setAttribute('xmlns', '');
            $propElem->appendChild($pElem);
        }
        $root->appendChild($propElem);

        // quality
        if(!empty($this->quality)) {
            $qElem = $dom->createElement('quality', $this->quality);
            $root->appendChild($qElem);
        }

        return $dom->saveXML();
    }
public function getAsXML()
    {

        // root
        $dom = new \DOMDocument();
        $root = $dom->createElement('metadata');
        $root->setAttribute('xmlns', 'http://marklogic.com/rest-api');
        $dom->appendChild($root);

        // collections
        $collElem = $dom->createElement('collections');
        foreach($this->collections as $v) {
            $collElem->appendChild($dom->createElement('collection', $v));
        }
        $root->appendChild($collElem);

        // permissions
        $permElem = $dom->createElement('permissions');
        foreach($this->permissions as $rn => $p) {
            $pElem = $dom->createElement('permission');
            $pElem->appendChild($dom->createElement('role-name', $p->getRoleName()));
            foreach($p->getCapabilities() as $c) {
                $pElem->appendChild($dom->createElement('capability', $c));
            }
            $permElem->appendChild($pElem);
        }
        $root->appendChild($permElem);

        // properties
        $propElem = $dom->createElement('prop:properties');
        $propElem->setAttribute('xmlns:prop', 'http://marklogic.com/xdmp/property');
        foreach($this->properties as $k => $v) {
            $pElem = $dom->createElement($k, $v);
            $pElem->setAttribute('xmlns', '');
            $propElem->appendChild($pElem);
        }
        $root->appendChild($propElem);

        // quality
        if(!empty($this->quality)) {
            $qElem = $dom->createElement('quality', $this->quality);
            $root->appendChild($qElem);
        }

        return $dom->saveXML();
    }
Get the metadata object as XML.

@return string The metadata as XML.