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