private function buildXml(\DOMNode
$parentNode, mixed
$data, string
$format, array
$context, string
$xmlRootNodeName = null
): bool
{ $append = true;
$removeEmptyTags =
$context[self::REMOVE_EMPTY_TAGS
] ??
$this->defaultContext
[self::REMOVE_EMPTY_TAGS
] ?? false;
$encoderIgnoredNodeTypes =
$context[self::ENCODER_IGNORED_NODE_TYPES
] ??
$this->defaultContext
[self::ENCODER_IGNORED_NODE_TYPES
];
if (\
is_array($data) || ($data instanceof \Traversable
&& (null ===
$this->serializer || !
$this->serializer->
supportsNormalization($data,
$format)))) { 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
)) {