diff --git a/components/serializer.rst b/components/serializer.rst index 96e3408c1be..9ce72892451 100644 --- a/components/serializer.rst +++ b/components/serializer.rst @@ -1162,6 +1162,23 @@ the key ``#comment`` can be used for encoding XML comments:: You can pass the context key ``as_collection`` in order to have the results always as a collection. +.. note:: + + You may need to add some attributes on the root node:: + + $encoder = new XmlEncoder(); + $encoder->encode([ + '@attribute1' => 'foo', + '@attribute2' => 'bar', + '#' => ['foo' => ['@bar' => 'value', '#' => 'baz']] + ], 'xml'); + + // will return: + // + // + // baz + // + .. tip:: XML comments are ignored by default when decoding contents, but this