From f126ce146bd7c3fa7f424096ce97db80148af7a9 Mon Sep 17 00:00:00 2001 From: Issam KHADIRI Date: Sat, 4 Jun 2022 13:36:34 +0200 Subject: [PATCH] Update serializer.rst Hello The `$encoderIgnoredNodeTypes` does not exist in the XmlEncoder's constructor and the $defaultContext argument should be used instead, So To escape the comments while encoding, we can either pass the `\XML_COMMENT_NODE` to the `XmlEncoder::ENCODER_IGNORED_NODE_TYPES` context option in the constructor or use it when calling the encode() method. --- components/serializer.rst | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/components/serializer.rst b/components/serializer.rst index 27d503e49ed..3a63fffe024 100644 --- a/components/serializer.rst +++ b/components/serializer.rst @@ -1108,8 +1108,10 @@ always as a collection. behavior can be changed with the optional context key ``XmlEncoder::DECODER_IGNORED_NODE_TYPES``. Data with ``#comment`` keys are encoded to XML comments by default. This can be - changed with the optional ``$encoderIgnoredNodeTypes`` argument of the - ``XmlEncoder`` class constructor. + changed by adding the ``\XML_COMMENT_NODE`` option to the ``XmlEncoder::ENCODER_IGNORED_NODE_TYPES`` key of the ``$defaultContext`` of the + ``XmlEncoder`` class constructor or directly to the encode() method's $context argument. + + $xmlEncoder->encode($array, 'xml', [XmlEncoder::ENCODER_IGNORED_NODE_TYPES => [\XML_COMMENT_NODE]]); The ``XmlEncoder`` Context Options ..................................