You are here

private function XmlEncoder::appendNode in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/serializer/Encoder/XmlEncoder.php \Symfony\Component\Serializer\Encoder\XmlEncoder::appendNode()

Selects the type of node to create and appends it to the parent.

Parameters

\DOMNode $parentNode:

array|object $data:

string $nodeName:

string $key:

Return value

bool

2 calls to XmlEncoder::appendNode()
XmlEncoder::buildXml in vendor/symfony/serializer/Encoder/XmlEncoder.php
Parse the data and convert it to DOMElements.
XmlEncoder::encode in vendor/symfony/serializer/Encoder/XmlEncoder.php
Encodes data into the given format.

File

vendor/symfony/serializer/Encoder/XmlEncoder.php, line 430

Class

XmlEncoder
Encodes XML data.

Namespace

Symfony\Component\Serializer\Encoder

Code

private function appendNode(\DOMNode $parentNode, $data, $nodeName, $key = null) {
  $node = $this->dom
    ->createElement($nodeName);
  if (null !== $key) {
    $node
      ->setAttribute('key', $key);
  }
  $appendNode = $this
    ->selectNodeType($node, $data);

  // we may have decided not to append this node, either in error or if its $nodeName is not valid
  if ($appendNode) {
    $parentNode
      ->appendChild($node);
  }
  return $appendNode;
}