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 @@ -1145,6 +1145,23 @@ the key ``#comment`` can be used for encoding XML comments::
1145
1145
You can pass the context key ``as_collection `` in order to have the results
1146
1146
always as a collection.
1147
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
+
1148
1165
.. tip ::
1149
1166
1150
1167
XML comments are ignored by default when decoding contents, but this
You can’t perform that action at this time.
0 commit comments