We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents ec6bf1c + 064d2ea commit 289d1efCopy full SHA for 289d1ef
components/serializer.rst
@@ -1145,6 +1145,23 @@ the key ``#comment`` can be used for encoding XML comments::
1145
You can pass the context key ``as_collection`` in order to have the results
1146
always as a collection.
1147
1148
+.. note::
1149
+
1150
+ You may need to add some attributes on the root node::
1151
1152
+ $encoder = new XmlEncoder();
1153
+ $encoder->encode([
1154
+ '@attribute1' => 'foo',
1155
+ '@attribute2' => 'bar',
1156
+ '#' => ['foo' => ['@bar' => 'value', '#' => 'baz']]
1157
+ ], 'xml');
1158
1159
+ // will return:
1160
+ // <?xml version="1.0"?>
1161
+ // <response attribute1="foo" attribute2="bar">
1162
+ // <foo bar="value">baz</foo>
1163
+ // </response>
1164
1165
.. tip::
1166
1167
XML comments are ignored by default when decoding contents, but this
0 commit comments