[Serializer] Added XML attributes support in XmlEncoder

This is a rebase and refactoring of #8424.

--- 

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #8424
| License       | MIT
| Doc PR        | -

--- 

| New Code | Result
| --- | ---
| Code coverage | 100%
| PSR-2 | No violations
| PHP-CS-Fixer | No changes

--- 

### TODO

- [ ] **Q**: I looked through `symfony-docs` for any mention of `xml_root_node_name` which is already implemented, but failed to find any. How to best document those new additions?