selectNodeType example

foreach ($data as $key => $data) {
                // Ah this is the magic @ attribute types.                 if (str_starts_with($key, '@') && $this->isElementNameValid($attributeName = substr($key, 1))) {
                    if (!\is_scalar($data)) {
                        $data = $this->serializer->normalize($data$format$context);
                    }
                    if (\is_bool($data)) {
                        $data = (int) $data;
                    }
                    $parentNode->setAttribute($attributeName$data);
                } elseif ('#' === $key) {
                    $append = $this->selectNodeType($parentNode$data$format$context);
                } elseif ('#comment' === $key) {
                    if (!\in_array(\XML_COMMENT_NODE, $encoderIgnoredNodeTypes, true)) {
                        $append = $this->appendComment($parentNode$data);
                    }
                } elseif (\is_array($data) && false === is_numeric($key)) {
                    // Is this array fully numeric keys?                     if (ctype_digit(implode('', array_keys($data)))) {
                        /* * Create nodes to append to $parentNode based on the $key of this array * Produces <xml><item>0</item><item>1</item></xml> * From ["item" => [0,1]];. */
foreach ($data as $key => $data) {
                // Ah this is the magic @ attribute types.                 if (str_starts_with($key, '@') && $this->isElementNameValid($attributeName = substr($key, 1))) {
                    if (!\is_scalar($data)) {
                        $data = $this->serializer->normalize($data$format$context);
                    }
                    if (\is_bool($data)) {
                        $data = (int) $data;
                    }
                    $parentNode->setAttribute($attributeName$data);
                } elseif ('#' === $key) {
                    $append = $this->selectNodeType($parentNode$data$format$context);
                } elseif ('#comment' === $key) {
                    if (!\in_array(\XML_COMMENT_NODE, $encoderIgnoredNodeTypes, true)) {
                        $append = $this->appendComment($parentNode$data);
                    }
                } elseif (\is_array($data) && false === is_numeric($key)) {
                    // Is this array fully numeric keys?                     if (ctype_digit(implode('', array_keys($data)))) {
                        /* * Create nodes to append to $parentNode based on the $key of this array * Produces <xml><item>0</item><item>1</item></xml> * From ["item" => [0,1]];. */
Home | Imprint | This part of the site doesn't use cookies.