You are here

private function XmlEncoder::parseXml 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::parseXml()

Parse the input DOMNode into an array or a string.

Parameters

\DOMNode $node xml to parse:

Return value

array|string

2 calls to XmlEncoder::parseXml()
XmlEncoder::decode in vendor/symfony/serializer/Encoder/XmlEncoder.php
Decodes a string into PHP data.
XmlEncoder::parseXmlValue in vendor/symfony/serializer/Encoder/XmlEncoder.php
Parse the input DOMNode value (content and children) into an array or a string.

File

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

Class

XmlEncoder
Encodes XML data.

Namespace

Symfony\Component\Serializer\Encoder

Code

private function parseXml(\DOMNode $node) {
  $data = $this
    ->parseXmlAttributes($node);
  $value = $this
    ->parseXmlValue($node);
  if (!count($data)) {
    return $value;
  }
  if (!is_array($value)) {
    $data['#'] = $value;
    return $data;
  }
  if (1 === count($value) && key($value)) {
    $data[key($value)] = current($value);
    return $data;
  }
  foreach ($value as $key => $val) {
    $data[$key] = $val;
  }
  return $data;
}