@@ -862,11 +862,14 @@ The ``XmlEncoder``
862
862
863
863
This encoder transforms arrays into XML and vice versa.
864
864
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::
866
867
867
868
array('foo' => array(1, 2), 'bar' => true);
868
869
869
- The ``XmlEncoder `` will encode this object like that::
870
+ The ``XmlEncoder `` encodes this object as follows:
871
+
872
+ .. code-block :: xml
870
873
871
874
<?xml version =" 1.0" ?>
872
875
<response >
@@ -875,7 +878,7 @@ The ``XmlEncoder`` will encode this object like that::
875
878
<bar >1</bar >
876
879
</response >
877
880
878
- Be aware that this encoder will consider keys beginning with ``@ `` as attributes::
881
+ The array keys beginning with ``@ `` are considered XML attributes::
879
882
880
883
$encoder = new XmlEncoder();
881
884
$encoder->encode(array('foo' => array('@bar' => 'value')));
@@ -894,7 +897,7 @@ It must be defined while calling the XmlEncoder encode() method::
894
897
895
898
$xmlEncoder->encode($array, 'xml', $context);
896
899
897
- **Available params : **
900
+ **Available params: **
898
901
899
902
``xml_format_output ``
900
903
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::
909
912
Add standalone attribute in XML output
910
913
911
914
``xml_root_node_name ``
912
- Change the root node name (default : response)
915
+ Change the root node name (default: response)
913
916
914
917
``remove_empty_tags ``
915
918
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
981
984
matches the type of the property (even for primitive types). For instance, if a ``string `` is provided, but
982
985
the type of the property is ``int ``, an :class: `Symfony\\ Component\\ Serializer\\ Exception\\ UnexpectedValueException `
983
986
will 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
984
1017
985
1018
Learn more
986
1019
----------
0 commit comments