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 @@ -1099,6 +1099,23 @@ the key ``#comment`` can be used for encoding XML comments::
1099
1099
You can pass the context key ``as_collection `` in order to have the results
1100
1100
always as a collection.
1101
1101
1102
+ .. note ::
1103
+
1104
+ You may need to add some attributes on the root node::
1105
+
1106
+ $encoder = new XmlEncoder();
1107
+ $encoder->encode([
1108
+ '@attribute1' => 'foo',
1109
+ '@attribute2' => 'bar',
1110
+ '#' => ['foo' => ['@bar' => 'value', '#' => 'baz']]
1111
+ ], 'xml');
1112
+
1113
+ // will return:
1114
+ // <?xml version="1.0"?>
1115
+ // <response attribute1="foo" attribute2="bar">
1116
+ // <foo bar="value">baz</foo>
1117
+ // </response>
1118
+
1102
1119
.. tip ::
1103
1120
1104
1121
XML comments are ignored by default when decoding contents, but this
You can’t perform that action at this time.
0 commit comments