@@ -862,11 +862,14 @@ The ``XmlEncoder``
862862
863863This encoder transforms arrays into XML and vice versa.
864864
865- For example, take an object normalized as following::
865+ This encoder transforms arrays into XML and vice versa. For example, take an
866+ object normalized as following::
866867
867868 array('foo' => array(1, 2), 'bar' => true);
868869
869- The ``XmlEncoder `` will encode this object like that::
870+ The ``XmlEncoder `` encodes this object as follows:
871+
872+ .. code-block :: xml
870873
871874 <?xml version =" 1.0" ?>
872875 <response >
@@ -875,7 +878,7 @@ The ``XmlEncoder`` will encode this object like that::
875878 <bar >1</bar >
876879 </response >
877880
878- Be aware that this encoder will consider keys beginning with ``@ `` as attributes::
881+ The array keys beginning with ``@ `` are considered XML attributes::
879882
880883 $encoder = new XmlEncoder();
881884 $encoder->encode(array('foo' => array('@bar' => 'value')));
@@ -894,7 +897,7 @@ It must be defined while calling the XmlEncoder encode() method::
894897
895898 $xmlEncoder->encode($array, 'xml', $context);
896899
897- **Available params : **
900+ **Available params: **
898901
899902``xml_format_output ``
900903 If set to true, format the output XML with line break and indentation
@@ -909,7 +912,7 @@ It must be defined while calling the XmlEncoder encode() method::
909912 Add standalone attribute in XML output
910913
911914``xml_root_node_name ``
912- Change the root node name (default : response)
915+ Change the root node name (default: response)
913916
914917``remove_empty_tags ``
915918 If set to true, remove all empty tags in the XML output
@@ -981,6 +984,36 @@ When a ``PropertyTypeExtractor`` is available, the normalizer will also check th
981984matches the type of the property (even for primitive types). For instance, if a ``string `` is provided, but
982985the type of the property is ``int ``, an :class: `Symfony\\ Component\\ Serializer\\ Exception\\ UnexpectedValueException `
983986will be thrown.
987+ =======
988+
989+ Context
990+ ~~~~~~~
991+
992+ The XmlEncoder ``encode() `` method defines a third optional parameter called
993+ ``context `` to define soem configuration options for the XmlEncoder::
994+
995+ $xmlEncoder->encode($array, 'xml', $context);
996+
997+ These are the options available:
998+
999+ ``xml_format_output ``
1000+ If set to true, format the output XML with line breaks and indentation.
1001+
1002+ ``xml_version ``
1003+ Change the XML version attribute.
1004+
1005+ ``xml_encoding ``
1006+ Change the XML encoding attribute.
1007+
1008+ ``xml_standalone ``
1009+ Add standalone attribute in XML output .
1010+
1011+ ``xml_root_node_name ``
1012+ Change the root node name (default: ``response ``).
1013+
1014+ ``remove_empty_tags ``
1015+ If set to true, remove all empty tags in the XML output.
1016+ >>>>>>> Minor syntax issues and some rewordings
9841017
9851018Learn more
9861019----------
0 commit comments