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