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::
10971097You can pass the context key ``as_collection `` in order to have the results
10981098always as a collection.
10991099
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+
11001117.. tip ::
11011118
11021119 XML comments are ignored by default when decoding contents, but this
You can’t perform that action at this time.
0 commit comments