Skip to content

Commit 289d1ef

Browse files
committed
Merge branch '6.3' into 6.4
* 6.3: Adding precision on how to define attributes on the root node for the XML Encoder
2 parents ec6bf1c + 064d2ea commit 289d1ef

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

components/serializer.rst

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1145,6 +1145,23 @@ the key ``#comment`` can be used for encoding XML comments::
11451145
You can pass the context key ``as_collection`` in order to have the results
11461146
always as a collection.
11471147

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+
11481165
.. tip::
11491166

11501167
XML comments are ignored by default when decoding contents, but this

0 commit comments

Comments
 (0)