Convert this element to XML.

@param \DOMElement $parent The element we should append to.
@return \DOMElement
@throws \Exception
499111
public function toXML(DOMElement $parent) : DOMElement
    {
        Assert::stringNotEmpty($this->Algorithm, 'Cannot convert DigestMethod to XML without an Algorithm set.');

        $doc = $parent->ownerDocument;
        $e = $doc->createElementNS(Common::NS, 'alg:DigestMethod');
        $parent->appendChild($e);
        $e->setAttribute('Algorithm', $this->Algorithm);

        return $e;
    }
350952
public function createElement(Node $parent, $name)
    {
        if (array_key_exists($name, $this->elementMap)) {
            $class = $this->elementMap[$name];

            return new $class($parent);
        }

        return null;
    }
1291355
protected function toXML(DOMElement $parent) : DOMElement
    {
        $e = $parent->ownerDocument->createElementNS(Constants::NS_MD, $this->elementName);
        $parent->appendChild($e);

        if ($this->ID !== null) {
            $e->setAttribute('ID', $this->ID);
        }

        if ($this->validUntil !== null) {
            $e->setAttribute('validUntil', gmdate('Y-m-d\TH:i:s\Z', $this->validUntil));
        }

        if ($this->cacheDuration !== null) {
            $e->setAttribute('cacheDuration', $this->cacheDuration);
        }

        $e->setAttribute('protocolSupportEnumeration', implode(' ', $this->protocolSupportEnumeration));

        if ($this->errorURL !== null) {
            $e->setAttribute('errorURL', $this->errorURL);
        }

        Extensions::addList($e, $this->Extensions);

        foreach ($this->KeyDescriptor as $kd) {
            $kd->toXML($e);
        }

        if ($this->Organization !== null) {
            $this->Organization->toXML($e);
        }

        foreach ($this->ContactPerson as $cp) {
            $cp->toXML($e);
        }

        return $e;
    }
286381
public function build(SimpleXMLElement $parent = null) : SimpleXMLElement
    {
        if ($parent === null) {
            $xml = new SimpleXMLElement('<' . get_called_class()::getTagName() . "/>", LIBXML_PARSEHUGE);
        } else {
            $xml = $parent->addChild(get_called_class()::getTagName());
        }
        $this->setAttributes($xml);
        $this->setChilds($xml);

        return $xml;
    }
402009
public function toXML(DOMElement $parent = null) : DOMElement
    {
        if ($parent === null) {
            $parent = DOMDocumentFactory::create();
            $doc = $parent;
        } else {
            $doc = $parent->ownerDocument;
        }
        $element = $doc->createElementNS(Constants::NS_SAML, $this->nodeName);
        $parent->appendChild($element);

        if ($this->NameQualifier !== null) {
            $element->setAttribute('NameQualifier', $this->NameQualifier);
        }

        if ($this->SPNameQualifier !== null) {
            $element->setAttribute('SPNameQualifier', $this->SPNameQualifier);
        }

        return $element;
    }
723110
public function toUnsignedXML() : DOMElement
    {
        $root = parent::toUnsignedXML();

        foreach ($this->attributes as $name => $values) {
            $attribute = $root->ownerDocument->createElementNS(Constants::NS_SAML, 'saml:Attribute');
            $root->appendChild($attribute);
            $attribute->setAttribute('Name', $name);

            if ($this->nameFormat !== Constants::NAMEFORMAT_UNSPECIFIED) {
                $attribute->setAttribute('NameFormat', $this->nameFormat);
            }

            foreach ($values as $value) {
                if (is_string($value)) {
                    $type = 'xs:string';
                } elseif (is_int($value)) {
                    $type = 'xs:integer';
                } else {
                    $type = null;
                }

                $attributeValue = Utils::addString(
                    $attribute,
                    Constants::NS_SAML,
                    'saml:AttributeValue',
                    strval($value)
                );
                if ($type !== null) {
                    $attributeValue->setAttributeNS(Constants::NS_XSI, 'xsi:type', $type);
                }
            }
        }

        return $root;
    }
730007
public function convert(\DOMElement $parent, TagDescriptor $tag)
    {
        $description = $this->getDescription($tag);

        $child = new \DOMElement('tag');
        $parent->appendChild($child);

        $child->setAttribute('name', str_replace('&', '&amp;', $tag->getName()));
        $child->setAttribute('line', $parent->getAttribute('line'));
        $child->setAttribute('description', str_replace('&', '&amp;', $description));
        $this->addTypes($tag, $child);

        // TODO: make the tests below configurable from the outside so that more could be added using plugins
        if (method_exists($tag, 'getVariableName')) {
            $child->setAttribute('variable', str_replace('&', '&amp;', $tag->getVariableName()));
        }
        if (method_exists($tag, 'getReference')) {
            $child->setAttribute('link', str_replace('&', '&amp;', $tag->getReference()));
        }
        if (method_exists($tag, 'getLink')) {
            $child->setAttribute('link', str_replace('&', '&amp;', $tag->getLink()));
        }
        if (method_exists($tag, 'getMethodName')) {
            $child->setAttribute('method_name', str_replace('&', '&amp;', $tag->getMethodName()));
        }

        return $child;
    }
2895
public function toXML(DOMElement $parent) : DOMElement
    {
        $e = $this->toXMLInternal($parent, Constants::NS_MD, 'md:RequestedAttribute');

        if (is_bool($this->isRequired)) {
            $e->setAttribute('isRequired', $this->isRequired ? 'true' : 'false');
        }

        return $e;
    }
290334
public function parseElement(Node $parent, \DOMElement $element)
    {
        if (Atom::NS !== $element->namespaceURI) {
            return null;
        }

        $name = 'atom:' . $element->localName;
        if (array_key_exists($name, $this->elementMap)) {
            $class = $this->elementMap[$name];

            return new $class($parent, $element);
        }

        return null;
    }
303836
private static function getStringElement(\DOMElement $parent, string $name) : ?string
    {
        $e = self::getStringElements($parent, $name);
        if (empty($e)) {
            return null;
        }
        if (count($e) > 1) {
            throw new \Exception('More than one '.$name.' in '.$parent->tagName);
        }

        return $e[0];
    }
398685
public function setParent(\Haven\CmsBundle\Entity\HtmlContent $parent = null)
    {
        $this->parent = $parent;
    
        return $this;
    }
423734
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;
    }
892417
public function toUnsignedXML() : DOMElement
    {
        if ($this->nameId === null) {
            throw new \Exception('Cannot convert SubjectQuery to XML without a NameID set.');
        }
        $root = parent::toUnsignedXML();

        $subject = $root->ownerDocument->createElementNS(Constants::NS_SAML, 'saml:Subject');
        $root->appendChild($subject);

        $this->nameId->toXML($subject);

        return $root;
    }
1208755
public function toUnsignedXML() : DOMElement
    {
        $root = parent::toUnsignedXML();

        /** @var \SAML2\Assertion|\SAML2\EncryptedAssertion $assertion */
        foreach ($this->assertions as $assertion) {
            $assertion->toXML($root);
        }

        return $root;
    }
1094696
public function parseElement(Node $parent, \DOMElement $element)
    {
        foreach ($this->registry[ElementExtension::class] as $extension) {
            $node = $extension->parseElement($parent, $element);
            if ($node) {
                return $node;
            }
        }

        return null;
    }
1296578
public function toXML(DOMElement $parent) : ?DOMElement
    {
        if (!empty($this->IPHint)
         || !empty($this->DomainHint)
         || !empty($this->GeolocationHint)
         || !empty($this->children)
        ) {
            $doc = $parent->ownerDocument;

            $e = $doc->createElementNS(Common::NS, 'mdui:DiscoHints');
            $parent->appendChild($e);

            foreach ($this->getChildren() as $child) {
                $child->toXML($e);
            }

            Utils::addStrings($e, Common::NS, 'mdui:IPHint', false, $this->IPHint);
            Utils::addStrings($e, Common::NS, 'mdui:DomainHint', false, $this->DomainHint);
            Utils::addStrings($e, Common::NS, 'mdui:GeolocationHint', false, $this->GeolocationHint);

            return $e;
        }

        return null;
    }
1025713
private function getFormNode(\DOMElement $element)
    {
        if ($element->hasAttribute('form')) {
            $formId = $element->getAttribute('form');
            $formNode = $element->ownerDocument->getElementById($formId);

            if (null === $formNode || 'form' !== $formNode->nodeName) {
                throw new DriverException(sprintf('The selected node has an invalid form attribute (%s).', $formId));
            }

            return $formNode;
        }

        $formNode = $element;

        do {
            // use the ancestor form element
            if (null === $formNode = $formNode->parentNode) {
                throw new DriverException('The selected node does not have a form ancestor.');
            }
        } while ('form' !== $formNode->nodeName);

        return $formNode;
    }