Creates and returns a new node with textNode, ready for appending

@param string $nodeName
@param string $nodeValue
@return object DOM node
544558
private function createNode($nodeName, $nodeValue, $cdata = false)
    {
        $node = $this->createElement($nodeName);
        if($cdata){
            $text = $this->createCDATASection($nodeValue);
        } else {
            $text = $this->createTextNode($nodeValue);
        }

        $node->appendChild($text);
        return $node;

    }
667672
public function nodePropertyChanged(NodeInterface $node, $propertyName, $oldValue, $value)
    {
        if (!$this->eventEmittingService->isEnabled()) {
            return;
        }

        if ($oldValue === $value) {
            return;
        }

        $this->changedNodes[$node->getContextPath()]['newLabel'] = $node->getLabel();
        $this->changedNodes[$node->getContextPath()]['node'] = $node;
    }
866547
public function addNode($parentNode, $name, $value = false)
    {
        // if $parentNode is a string, it is likely to be
        // an XPath expression. If so, it is converted
        // into a DOMElement.
        if (is_string($parentNode)) {
            if ($parentNode == "/") {
                $parentNode = $this->domDocument;
            } else {
                $parentNode = $this->getNode($parentNode);
            }
        }

        if ($parentNode) {
            try {
                $newNode = $this->domDocument->createElement($name);
                if (!is_array($value) && !is_resource($value)) {
                    $newNode->appendChild(
                        $this->domDocument->createTextNode($value)
                    );
                }

                return $parentNode->appendChild($newNode);
            } catch (\DOMException $exception) {
                throw new Dom\Exception("Could not add node named '$name'.");
            }
        } else {
            throw new Dom\Exception("Parent node not found: " . $parentNode);
        }
    }
786317
public function toXML(DOMDocument $doc, $nodeName = "")
    {
        $text = $doc->createTextNode(gmdate("Y-m-d\TH:i:s\Z", $this->getValue()));
        $node = $doc->createElement("date");
        $node->appendChild($text);
        return $node;
    }
1350832
private function addNewXmlElement(DOMDocument $dom, DOMElement $node, $name, $value)
    {
        $new = $dom->createElement($name);
        $new->appendChild($dom->createTextNode($value));
        $node->appendChild($new);
    }
746352
private static function getOrCreateNode(DOMElement $svg, $tagName, $value)
    {
        $node = $svg->getElementsByTagName($tagName);

        if ($node->length) {
            $node = $node->item(0);
            $node->nodeValue = $value;
            
            return $node;
        }

        $newNode = new DOMElement($tagName, $value);
        $svg->appendChild($newNode);

        return $newNode;
    }
235603
protected function createAttributes(\DOMNodeList $nodeList, ObjectManager $manager)
    {
        /** @var \DOMNode $element */
        foreach ($nodeList as $element) {
            $attribute = new Attribute();
            $children = $element->childNodes;

            /** @var \DOMNode $child */
            foreach ($children as $child) {
                if (isset($child->nodeName) && $child->nodeName === 'key') {
                    $attribute->setKey($child->nodeValue);
                    continue;
                }
                if (isset($child->nodeName) && $child->nodeName === 'type') {
                    $type = $this->getType($child->nodeValue);

                    $attribute->setType($type);
                    continue;
                }

                /** @var \DOMNode $childNode */
                foreach ($child->childNodes as $childNode) {
                    switch ($childNode->nodeName) {
                        case 'name':
                            $locale = $childNode->attributes->getNamedItem('locale')->nodeValue;
                            $translation = $this->createAttributeTranslation(
                                $childNode->nodeValue,
                                $locale,
                                $attribute
                            );
                            $manager->persist($translation);

                            break;
                        case 'value':
                            $this->createAttributeValue($attribute, $childNode, $manager);

                            break;
                    }
                }
            }
            $manager->persist($attribute);
        }

        $manager->flush();
    }
247063
protected function fieldToElementWithAttribute(DOMDocument $doc, string $value, $node_name): DOMElement
    {
        $item = $this->fieldToElement($doc, $value);
        $item->setAttribute($this->column_attr, (string) $node_name);

        return $item;
    }
777736
protected static function renderNode($node, $document)
    {
        if (static::isTag($node)) {
            # Strip the leading "#"
            $tagName    = substr(array_shift($node), 1);
            $attributes = array();

            if (sizeof($node) > 2) {
                throw new \UnexpectedValueException(
                    "Tags must not consist of more than three elements"
                );
            }

            foreach ($node as $argv) {
                # Is the argument an associative array of attributes?
                if (is_array($argv) and count(array_filter(array_keys($argv), "is_string")) > 0) {
                    $attributes = $argv;
                } else {
                    $content = $argv;
                }
            }

            $el = $document->createElement($tagName);

            foreach ($attributes as $attr => $value) {
                if (is_array($value)) $value = join(" ", $value);

                $el->setAttribute($attr, (string) $value);
            }

            if (isset($content)) {
                $el->appendChild(static::renderNode($content, $document));
            }
        } else if (is_array($node)) {
            $el = $document->createDocumentFragment();

            foreach ($node as $child) {
                $el->appendChild(static::renderNode($child, $document));
            }
        } else {
            $node = (string) $node;
            if (!empty($node)) $node .= "\n";
            $el = $document->createTextNode($node);
        }

        return $el;
    }
1367112
protected function addCdataNode($nodeName, $value, array $attributes = array())
    {
        // create element
        $domElement = $this->getDomElement()->ownerDocument->createElement($nodeName);
        $this->getDomElement()->appendChild($domElement);

        // create cdata
        $cdata = $this->getDomElement()->ownerDocument->createCDATASection($value);
        $domElement->appendChild($cdata);

        // add attributes
        foreach ($attributes as $attributeId => $attributeValue) {
            $domElement->setAttribute($attributeId, $attributeValue);
        }

        return $this;
    }
931175
public static function create($name = 'null') {
    $is_upper = FormatterFactory::getDefaultFormatter()->getConfig('boolean_null_upper');
    $node = new NullNode();
    $node->addChild(NameNode::create($is_upper ? 'NULL' : 'null'), 'constantName');
    return $node;
  }
685030
private function handleValue( $value, DOMDocument $domDocument )
    {
        switch ( gettype( $value ) )
        {
            case 'integer':
                $node = $domDocument->createElement( 'int', $value );
                break;

            case 'boolean':
                $node = $domDocument->createElement( 'boolean', $value );
                break;

            case 'string':
                $node = $domDocument->createElement( 'string', $value );
                break;

            case 'double':
                $node = $domDocument->createElement( 'double', $value );
                break;

            case 'array':
                // array
                if ( empty( $value ) || key( $value ) === 0 )
                {
                    $node = $domDocument->createElement( 'array' );
                    $dataNode = $domDocument->createElement( 'data' );
                    $node->appendChild( $dataNode );

                    foreach ( $value as $cell )
                    {
                        $valueNode = $domDocument->createElement( 'value' );
                        $valueNode->appendChild( $this->handleValue( $cell, $domDocument ) );
                        $dataNode->appendChild( $valueNode );
                    }
                }
                // hash
                else
                {
                    $node = $domDocument->createElement( 'struct' );

                    foreach ( $value as $name => $cell )
                    {
                        // //member
                        $memberNode = $domDocument->createElement( 'member' );

                        // //member/name
                        $memberNode->appendChild( $domDocument->createElement( 'name', $name ) );

                        // //member/value
                        $valueNode = $domDocument->createElement( 'value' );
                        $memberNode->appendChild( $valueNode );
                        // //member/value/*
                        $valueNode->appendChild( $this->handleValue( $cell, $domDocument ) );

                        $node->appendChild( $memberNode );
                    }
                }
                break;

            case 'object':
                {
                    // DateTime is okay
                    if ( !$value instanceof DateTime )
                        continue;
                    $node = $domDocument->createElement( 'dateTime.iso8601', $value->format( DateTime::ISO8601 ) );
                }
                break;

            default:
                {
                    throw new \UnexpectedValueException( "Unknown return value type" );
                }
        }

        return $node;
    }
376313
public static function createDocumentFromNode(\DOMNode $node, $docOptions = 0)
    {
        $xmldoc = self::createXmlDocument($docOptions);
        XmlUtil::$xmlNsPrefix[spl_object_hash($xmldoc)] = array();
        $root = $xmldoc->importNode($node, true);
        $xmldoc->appendChild($root);
        return $xmldoc;
    }
1367897
public function appendChildWithText(NodeElement $nodeElement, $text, $append = true)
    {
        $content = $nodeElement->render();

        if ($append === true) {
            $content = $content.$text;
        } else {
            $content = $text.$content;
        }

        $this->setText($content);
        return $this;
    }
1047611
protected function getValuesOfArrayNode($nodeName)
    {
        $domElements = $this->getDomElement()->getElementsByTagName($nodeName);

        $values = array();
        for ($i = 0; $i < $domElements->length; $i++) {
            $values[$i] = $domElements->item($i)->nodeValue;
        }

        return $values;
    }
793246
static function createAttributeLookupElement( $attributeValues = array(), $variablePlacement = false )
    {
        if ( is_numeric( $attributeValues ) )
            $attributeValues = array( eZTemplateNodeTool::createNumericElement( $attributeValues, $variablePlacement ) );
        else if ( !is_array( $attributeValues ) )
            $attributeValues = array( eZTemplateNodeTool::createStringElement( $attributeValues, $variablePlacement ) );
        return array( eZTemplate::TYPE_ATTRIBUTE,
                      $attributeValues, $variablePlacement );
    }
25280
protected function getNodeValuesByTagName(DOMElement $node, $tagName)
    {
        $values = array();
        $results = $node->getElementsByTagName($tagName);
        if ($results->length) {
            foreach ($results as $result) {
                if ($result->nodeValue) {
                    $values[] = $result->nodeValue;
                }
            }
        }

        return $values;
    }