@param \DOMDocument $document

@return \DOMElement
352120
public function getXML(\DOMDocument $document)
    {
        $xml = $document->createElement('ns2:CreditCardData');
        if (!empty($this->cardNumber)) {
            $cardNumber              = $document->createElement('ns1:CardNumber');
            $cardNumber->textContent = $this->cardNumber;
            $xml->appendChild($cardNumber);
        }
        $expMonth = $document->createElement('ns1:ExpMonth');
        $expMonth->textContent = $this->expMonth;
        $expYear = $document->createElement('ns1:ExpYear');
        $expYear->textContent = $this->expYear;

        $xml->appendChild($expMonth);
        $xml->appendChild($expYear);

        return $xml;
    }
1145383
private function hydrateEntity($document)
    {
        $class = $this->entityClass;
        $reflectionClass = new \ReflectionClass(AbstractDocument::class);
        $entity = new $class();

        if (!($entity instanceof AbstractDocument)) {
            throw new \Exception(sprintf('"%s" is not a subclass of "%s"', $this->entityClass, AbstractDocument::class));
        }

        $documentProperty = $reflectionClass->getProperty('document');
        $documentProperty->setAccessible(true);
        $documentProperty->setValue($entity, $document);

        return $entity;
    }
342915
public function toXML(DOMElement $parent) : DOMElement
    {
        Assert::same($this->getElement()->namespaceURI, Constants::NS_SAML);
        Assert::same($this->getElement()->localName, "AttributeValue");

        return Utils::copyElement($this->element, $parent);
    }
1307466
public function toXML(DOMDocument $doc, $nodeName = "")
    {
        $node = $doc->createElement($nodeName);
        $text = $doc->createTextNode($this->value);
        $node->appendChild($text);
        return $node;
    }
1229927
public function parseDocument(\DOMDocument $document)
    {
        $doc = $this->extensions->parseDocument($document);
        if ($doc) {
            return $doc;
        }

        throw new \InvalidArgumentException(
            sprintf('Unexpected root element "%s"', $document->documentElement->localName)
        );
    }
419989
private function createMetadataNode(\DOMDocument $document, string $type = null): \DOMNode
    {
        $node = $document->createElement('object');
        if (null !== $type) {
            $node->setAttribute('type', $type);
        }

        return $node;
    }
855187
public function setElement($document, $element = null)
    {
        if (empty($document)) {
            // Make sure we always have an element to query against which should not return any returns.
            $document = new DOMDocument();
            $document->loadXML('<dummy/>');
        }
        $this->document = $document;

        if (empty($element)) {
            $element = $this->document->documentElement;
        }
        $this->element = $element;
    }
1237297
protected static function nodeToXpath(\DOMNode $domnode) {
		$dom = new \DOMDocument();
		$dom->formatOutput = true;
		$node = $dom->importNode($domnode, true);
		if($node instanceof \DOMElement)
			$dom->appendChild($node);
		return new \DOMXPath($dom);
	}
1287281
protected function scrapeAndKneadImages( \DOMDocument $doc ) {

		$images = $doc->getElementsByTagName( 'img' );
		foreach ( $images as $image ) {
			/** @var \DOMElement $image */
			// Fetch image, change src
			$old_src = $image->getAttribute( 'src' );
			$new_src = $this->fetchAndSaveUniqueImage( $old_src );
			if ( $new_src ) {
				// Replace with new image
				$image->setAttribute( 'src', $new_src );
			} else {
				// Tag broken image
				$image->setAttribute( 'src', "{$old_src}#fixme" );
			}
		}

		return $doc;
	}
390101
public function toXML(DOMDocument $doc, $nodeName = "")
    {
        $node = $doc->createElement('array');

        foreach ($this->value as $value) {
            $node->appendChild($value->toXML($doc));
        }
        return $node;
    }
584835
public function render(\DOMDocument $domDocument)
    {
        $quad = new Quad();
        $quad->setVisible(false);

        return $quad->render($domDocument);
    }
114890
public function toXML(DOMNode $parentElement = null) : DOMElement
    {
        if ($parentElement === null) {
            $document = DOMDocumentFactory::create();
            $parentElement = $document;
        } else {
            $document = $parentElement->ownerDocument;
        }

        $root = $document->createElementNS(Constants::NS_SAML, 'saml:'.'EncryptedAssertion');
        $parentElement->appendChild($root);

        $root->appendChild($document->importNode($this->encryptedData, true));

        return $root;
    }
586064
private function fillElement (DOMDocument $doc, DOMElement $parent, array $filler)
    {
        foreach ($filler as $name => $value) {
            if ($value instanceof DOMElement) {
                $element = $value;
            } else {
                $element = $doc->createElement($name);
                
                if (is_array($value)) {
                    $this->fillElement($doc, $element, $value);
                } else {
                    $element->appendChild(new DOMCdataSection($value));
                }
            }
            
            $parent->appendChild($element);
        }
    }
654951
public function process(\DOMDocument $xml)
    {
        $xpath = new \DOMXPath($xml);
        $nodes = $xpath->query(
            '/project/file/class/docblock/tag[@name="method"]'
        );

        /** @var \DOMElement $node */
        foreach ($nodes as $node) {
            $class = $node->parentNode->parentNode;

            $method = new \DOMElement('method');
            $class->appendChild($method);

            // set basic information
            $method->setAttribute('final', 'false');
            $method->setAttribute('static', 'false');
            $method->setAttribute('visibility', 'public');
            $method->setAttribute('line', $node->getAttribute('line'));
            $method->appendChild(
                new \DOMElement('name', $node->getAttribute('method_name'))
            );

            // fill docblock
            $docblock = new \DOMElement('docblock');
            $method->appendChild($docblock);
            $docblock->appendChild(
                new \DOMElement('description', $node->getAttribute('description'))
            );
            $docblock->appendChild(new \DOMElement('long-description'));

            // for each argument; create an @param tag and an argument element
            /** @var \DOMElement $argument */
            foreach ($node->getElementsByTagName('argument') as $argument) {
                $param_tag = new \DOMElement('tag');
                $docblock->appendChild($param_tag);
                $param_tag->setAttribute('name', 'param');
                $param_tag->setAttribute(
                    'type',
                    $argument->getElementsByTagName('type')->item(0)->nodeValue
                );
                $param_tag->setAttribute(
                    'variable',
                    $argument->getElementsByTagName('name')->item(0)->nodeValue
                );
                $param_tag->setAttribute('line', $node->getAttribute('line'));

                $types = explode(
                    '|',
                    $argument->getElementsByTagName('type')->item(0)->nodeValue
                );

                foreach ($types as $type) {
                    $type_element = new \DOMElement('type', $type);
                    $param_tag->appendChild($type_element);
                }

                $argument_element = $argument->cloneNode(true);
                $method->appendChild($argument_element);
            }

            // add a tag 'magic'
            $magic_tag = new \DOMElement('tag');
            $docblock->appendChild($magic_tag);
            $magic_tag->setAttribute('name', 'magic');
            $magic_tag->setAttribute('line', $node->getAttribute('line'));

            // add a @return tag
            $return_tag = new \DOMElement('tag');
            $docblock->appendChild($return_tag);
            $return_tag->setAttribute('name', 'return');
            $return_tag->setAttribute('line', $node->getAttribute('line'));
            $return_tag->setAttribute('type', $node->getAttribute('type'));

            // add type sub elements to the param
            foreach (explode('|', $node->getAttribute('type')) as $type) {
                $type_element = new \DOMElement('type', $type);
                $return_tag->appendChild($type_element);
            }

            // remove the tag, it is unneeded
            $node->parentNode->removeChild($node);
            $docblock->appendChild($node);
        }

        return $xml;
    }
1190233
public function dispatch(DOMDocument $document)
    {
        $documentNamespace = $document->documentElement->lookupNamespaceURI(null);
        // checking for null as ezxml has no default namespace...
        if ($documentNamespace === null) {
            $documentNamespace = $document->documentElement->lookupNamespaceURI('xhtml');
        }

        foreach ($this->mapping as $namespace => $converter) {
            if ($documentNamespace === $namespace) {
                if ($converter === null) {
                    return $document;
                }

                return $converter->convert($document);
            }
        }

        throw new NotFoundException('Converter', $documentNamespace);
    }
920597
protected function asXml(DomDocument $document)
    {
        $root = $document->createElement($this->getTagName(), $this->content);
        $document->appendChild($root);

        foreach ($this->attributes as $name => $value) {
            $root->setAttribute($name, $value);
        }

        foreach ($this->children as $child) {
            $root->appendChild($child->asXml($document));
        }

        return $root;
    }
178493
public function toXhtml(\DOMDocument $document, \DOMElement $root)
    {
        $content = '';

        /** @var \ezcDocumentRstToken $token */
        foreach ($this->node->tokens as $token) {
            $content .= $token->content;
        }

        $content = rtrim($content, "\n");

        $pre = $document->createElement('pre');
        $root->appendChild($pre);
        $code = $document->createElement('code', $content);
        $pre->appendChild($code);
    }