private function XmlEncoder::selectNodeType in Zircon Profile 8.0
Same name and namespace in other branches
- 8 vendor/symfony/serializer/Encoder/XmlEncoder.php \Symfony\Component\Serializer\Encoder\XmlEncoder::selectNodeType()
Tests the value being passed and decide what sort of element to create.
Parameters
\DOMNode $node:
mixed $val:
Return value
bool
2 calls to XmlEncoder::selectNodeType()
- XmlEncoder::appendNode in vendor/
symfony/ serializer/ Encoder/ XmlEncoder.php - Selects the type of node to create and appends it to the parent.
- XmlEncoder::buildXml in vendor/
symfony/ serializer/ Encoder/ XmlEncoder.php - Parse the data and convert it to DOMElements.
File
- vendor/
symfony/ serializer/ Encoder/ XmlEncoder.php, line 465
Class
- XmlEncoder
- Encodes XML data.
Namespace
Symfony\Component\Serializer\EncoderCode
private function selectNodeType(\DOMNode $node, $val) {
if (is_array($val)) {
return $this
->buildXml($node, $val);
}
elseif ($val instanceof \SimpleXMLElement) {
$child = $this->dom
->importNode(dom_import_simplexml($val), true);
$node
->appendChild($child);
}
elseif ($val instanceof \Traversable) {
$this
->buildXml($node, $val);
}
elseif (is_object($val)) {
return $this
->buildXml($node, $this->serializer
->normalize($val, $this->format, $this->context));
}
elseif (is_numeric($val)) {
return $this
->appendText($node, (string) $val);
}
elseif (is_string($val) && $this
->needsCdataWrapping($val)) {
return $this
->appendCData($node, $val);
}
elseif (is_string($val)) {
return $this
->appendText($node, $val);
}
elseif (is_bool($val)) {
return $this
->appendText($node, (int) $val);
}
elseif ($val instanceof \DOMNode) {
$child = $this->dom
->importNode($val, true);
$node
->appendChild($child);
}
return true;
}