File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -1162,6 +1162,23 @@ the key ``#comment`` can be used for encoding XML comments::
1162
1162
You can pass the context key ``as_collection `` in order to have the results
1163
1163
always as a collection.
1164
1164
1165
+ .. note ::
1166
+
1167
+ You may need to add some attributes on the root node::
1168
+
1169
+ $encoder = new XmlEncoder();
1170
+ $encoder->encode([
1171
+ '@attribute1' => 'foo',
1172
+ '@attribute2' => 'bar',
1173
+ '#' => ['foo' => ['@bar' => 'value', '#' => 'baz']]
1174
+ ], 'xml');
1175
+
1176
+ // will return:
1177
+ // <?xml version="1.0"?>
1178
+ // <response attribute1="foo" attribute2="bar">
1179
+ // <foo bar="value">baz</foo>
1180
+ // </response>
1181
+
1165
1182
.. tip ::
1166
1183
1167
1184
XML comments are ignored by default when decoding contents, but this
You can’t perform that action at this time.
0 commit comments