You are here

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

Parse the input DOMNode attributes into an array.

Parameters

\DOMNode $node xml to parse:

Return value

array

1 call to XmlEncoder::parseXmlAttributes()
XmlEncoder::parseXml in vendor/symfony/serializer/Encoder/XmlEncoder.php
Parse the input DOMNode into an array or a string.

File

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

Class

XmlEncoder
Encodes XML data.

Namespace

Symfony\Component\Serializer\Encoder

Code

private function parseXmlAttributes(\DOMNode $node) {
  if (!$node
    ->hasAttributes()) {
    return array();
  }
  $data = array();
  foreach ($node->attributes as $attr) {
    if (ctype_digit($attr->nodeValue)) {
      $data['@' . $attr->nodeName] = (int) $attr->nodeValue;
    }
    else {
      $data['@' . $attr->nodeName] = $attr->nodeValue;
    }
  }
  return $data;
}