[Serializer] Add xml_format_output context option. Close #12517.

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #12517
| License       | MIT
| Doc PR        | n/a