public function toXML(DOMElement $parent) : DOMElement
    {
        Assert::notEmpty($this->lang, "Cannot convert Keywords to XML without a language set.");

        $doc = $parent->ownerDocument;

        $e = $doc->createElementNS(Common::NS, 'mdui:Keywords');
        $e->setAttribute('xml:lang', $this->lang);
        $value = '';
        foreach ($this->Keywords as $keyword) {
            if (strpos($keyword, "+") !== false) {
                throw new \Exception('Keywords may not contain a "+" character.');
            }
            $value .= str_replace(' ', '+', $keyword).' ';
        }
        $value = rtrim($value);
        $e->appendChild($doc->createTextNode($value));
        $parent->appendChild($e);

        return $e;
    }
public function toXML(DOMElement $parent) : DOMElement
    {
        Assert::notEmpty($this->lang, "Cannot convert Keywords to XML without a language set.");

        $doc = $parent->ownerDocument;

        $e = $doc->createElementNS(Common::NS, 'mdui:Keywords');
        $e->setAttribute('xml:lang', $this->lang);
        $value = '';
        foreach ($this->Keywords as $keyword) {
            if (strpos($keyword, "+") !== false) {
                throw new \Exception('Keywords may not contain a "+" character.');
            }
            $value .= str_replace(' ', '+', $keyword).' ';
        }
        $value = rtrim($value);
        $e->appendChild($doc->createTextNode($value));
        $parent->appendChild($e);

        return $e;
    }
public function toXML ( DOMElement $ parent ) : DOMElement { Assert :: notEmpty ( $ this -> lang , "Cannot convert Keywords to XML without a language set." ) ; $ doc = $ parent -> ownerDocument ; $ e = $ doc -> createElementNS ( Common :: NS , 'mdui:Keywords' ) ; $ e -> setAttribute ( 'xml:lang' , $ this -> lang ) ; $ value = '' ; foreach ( $ this -> Keywords as $ keyword ) { if ( strpos ( $ keyword , "+" ) !== false ) { throw new \ Exception ( 'Keywords may not contain a "+" character.' ) ; } $ value .= str_replace ( ' ' , '+' , $ keyword ) . ' ' ; } $ value = rtrim ( $ value ) ; $ e -> appendChild ( $ doc -> createTextNode ( $ value ) ) ; $ parent -> appendChild ( $ e ) ; return $ e ; }
Convert this Keywords to XML.

@param \DOMElement $parent The element we should append this Keywords to.
@throws \Exception
@return \DOMElement
Convert this Keywords to XML .