From 0163ab399562c2a84acee070dee73b79d843434d Mon Sep 17 00:00:00 2001 From: armin-github Date: Thu, 27 Feb 2020 17:50:51 +0100 Subject: [PATCH] addressed issue #11786 The following issue has been addressed: Repeated entry in the Serializer components doc #11786 The separate documentations for XMLEncoder were put into one section with minor changes in text. The documentation now contains one single section for XMLEncoder. --- components/serializer.rst | 110 +++++++++++++++----------------------- 1 file changed, 42 insertions(+), 68 deletions(-) diff --git a/components/serializer.rst b/components/serializer.rst index eba1e0a57cc..fdc34fb6f44 100644 --- a/components/serializer.rst +++ b/components/serializer.rst @@ -841,8 +841,20 @@ The ``XmlEncoder`` will encode this object like that:: 1 -Be aware that this encoder will consider keys beginning with ``@`` as attributes, and will use -the key ``#comment`` for encoding XML comments:: +The special ``#`` key can be used to define the data of a node:: + + ['foo' => ['@bar' => 'value', '#' => 'baz']]; + + // is encoded as follows: + // + // + // + // baz + // + // + +Furthermore, keys beginning with ``@`` will be considered attributes, and +the key ``#comment`` can be used for encoding XML comments:: $encoder = new XmlEncoder(); $encoder->encode([ @@ -869,6 +881,34 @@ always as a collection. changed with the optional ``$encoderIgnoredNodeTypes`` argument of the ``XmlEncoder`` class constructor. +The ``XmlEncoder`` Context Options +.................................. + +The ``encode()`` method defines a third optional parameter called ``context`` +which defines the configuration options for the XmlEncoder an associative array:: + + $xmlEncoder->encode($array, 'xml', $context); + +These are the options available: + +``xml_format_output`` + If set to true, formats the generated XML with line breaks and indentation. + +``xml_version`` + Sets the XML version attribute (default: ``1.1``). + +``xml_encoding`` + Sets the XML encoding attribute (default: ``utf-8``). + +``xml_standalone`` + Adds standalone attribute in the generated XML (default: ``true``). + +``xml_root_node_name`` + Sets the root node name (default: ``response``). + +``remove_empty_tags`` + If set to true, removes all empty tags in the generated XML (default: ``false``). + The ``YamlEncoder`` ~~~~~~~~~~~~~~~~~~~ @@ -1192,72 +1232,6 @@ you indicate that you're expecting an array instead of a single object:: $data = ...; // The serialized data from the previous example $persons = $serializer->deserialize($data, 'Acme\Person[]', 'json'); -The ``XmlEncoder`` ------------------- - -This encoder transforms arrays into XML and vice versa. For example, take an -object normalized as following:: - - ['foo' => [1, 2], 'bar' => true]; - -The ``XmlEncoder`` encodes this object as follows: - -.. code-block:: xml - - - - 1 - 2 - 1 - - -The array keys beginning with ``@`` are considered XML attributes:: - - ['foo' => ['@bar' => 'value']]; - - // is encoded as follows: - // - // - // - // - -Use the special ``#`` key to define the data of a node:: - - ['foo' => ['@bar' => 'value', '#' => 'baz']]; - - // is encoded as follows: - // - // - // baz - // - -Context -~~~~~~~ - -The ``encode()`` method defines a third optional parameter called ``context`` -which defines the configuration options for the XmlEncoder an associative array:: - - $xmlEncoder->encode($array, 'xml', $context); - -These are the options available: - -``xml_format_output`` - If set to true, formats the generated XML with line breaks and indentation. - -``xml_version`` - Sets the XML version attribute (default: ``1.1``). - -``xml_encoding`` - Sets the XML encoding attribute (default: ``utf-8``). - -``xml_standalone`` - Adds standalone attribute in the generated XML (default: ``true``). - -``xml_root_node_name`` - Sets the root node name (default: ``response``). - -``remove_empty_tags`` - If set to true, removes all empty tags in the generated XML (default: ``false``). The ``CsvEncoder`` ------------------ pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy