Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 8243c48

Browse filesBrowse files
committed
minor #19192 Adding precision on how to define attributes on the root node for the XML Encoder (ktherage)
This PR was submitted for the 6.3 branch but it was squashed and merged into the 5.4 branch instead. Discussion ---------- Adding precision on how to define attributes on the root node for the XML Encoder This pull request aims to clarify a point that was not clearly exposed in the documentation when trying to define attributes on the root node for XML. Commits ------- c09286e Adding precision on how to define attributes on the root node for the XML Encoder
2 parents 7be1bde + c09286e commit 8243c48
Copy full SHA for 8243c48

File tree

Expand file treeCollapse file tree

1 file changed

+17
-0
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+17
-0
lines changed

‎components/serializer.rst

Copy file name to clipboardExpand all lines: components/serializer.rst
+17Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1162,6 +1162,23 @@ the key ``#comment`` can be used for encoding XML comments::
11621162
You can pass the context key ``as_collection`` in order to have the results
11631163
always as a collection.
11641164

1165+
.. note::
1166+
1167+
You may need to add some attributes on the root node::
1168+
1169+
$encoder = new XmlEncoder();
1170+
$encoder->encode([
1171+
'@attribute1' => 'foo',
1172+
'@attribute2' => 'bar',
1173+
'#' => ['foo' => ['@bar' => 'value', '#' => 'baz']]
1174+
], 'xml');
1175+
1176+
// will return:
1177+
// <?xml version="1.0"?>
1178+
// <response attribute1="foo" attribute2="bar">
1179+
// <foo bar="value">baz</foo>
1180+
// </response>
1181+
11651182
.. tip::
11661183

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

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.