 .../rest/src/Tests/Views/StyleSerializerTest.php   | 118 ++++-----------------
 .../tests/modules/rest_test/rest_test.services.yml |   5 +
 .../rest_test/src/RestTestServiceProvider.php      |  22 ++++
 .../EntityResource/EntityResourceTestBase.php      |   4 +-
 core/modules/serialization/serialization.info.yml  |   2 +-
 core/modules/serialization/serialization.module    |   4 +-
 .../serialization/serialization.services.yml       |   4 -
 .../serialization/src/Encoder/XmlEncoder.php       |   3 +
 .../tests/src/Kernel/EntitySerializationTest.php   |  30 +-----
 .../tests/src/Unit/Encoder/XmlEncoderTest.php      |  79 --------------
 .../tests/src/Functional/UserLoginHttpTest.php     |   5 +-
 11 files changed, 61 insertions(+), 215 deletions(-)

diff --git a/core/modules/rest/src/Tests/Views/StyleSerializerTest.php b/core/modules/rest/src/Tests/Views/StyleSerializerTest.php
index 4c004fc..8f6fa7b 100644
--- a/core/modules/rest/src/Tests/Views/StyleSerializerTest.php
+++ b/core/modules/rest/src/Tests/Views/StyleSerializerTest.php
@@ -177,43 +177,6 @@ public function testSerializerResponses() {
     $actual_json = $this->drupalGetWithFormat('test/serialize/entity', 'hal_json');
     $this->assertIdentical($actual_json, $expected, 'The expected HAL output was found.');
     $this->assertCacheTags($expected_cache_tags);
-
-    // Change the default format to xml.
-    $view->setDisplay('rest_export_1');
-    $view->getDisplay()->setOption('style', array(
-      'type' => 'serializer',
-      'options' => array(
-        'uses_fields' => FALSE,
-        'formats' => array(
-          'xml' => 'xml',
-        ),
-      ),
-    ));
-    $view->save();
-    $expected = $serializer->serialize($entities, 'xml');
-    $actual_xml = $this->drupalGet('test/serialize/entity');
-    $this->assertIdentical($actual_xml, $expected, 'The expected XML output was found.');
-    $this->assertCacheContexts(['languages:language_interface', 'theme', 'entity_test_view_grants', 'request_format']);
-
-    // Allow multiple formats.
-    $view->setDisplay('rest_export_1');
-    $view->getDisplay()->setOption('style', array(
-      'type' => 'serializer',
-      'options' => array(
-        'uses_fields' => FALSE,
-        'formats' => array(
-          'xml' => 'xml',
-          'json' => 'json',
-        ),
-      ),
-    ));
-    $view->save();
-    $expected = $serializer->serialize($entities, 'json');
-    $actual_json = $this->drupalGetWithFormat('test/serialize/entity', 'json');
-    $this->assertIdentical($actual_json, $expected, 'The expected JSON output was found.');
-    $expected = $serializer->serialize($entities, 'xml');
-    $actual_xml = $this->drupalGetWithFormat('test/serialize/entity', 'xml');
-    $this->assertIdentical($actual_xml, $expected, 'The expected XML output was found.');
   }
 
   /**
@@ -292,8 +255,7 @@ public function testRestRenderCaching() {
 
     $this->assertFalse($render_cache->get($original));
 
-    // Request the page, once in XML and once in JSON to ensure that the caching
-    // varies by it.
+    // Request the page in JSON.
     $result1 = $this->drupalGetJSON('test/serialize/entity');
     $this->addRequestWithFormat('json');
     $this->assertHeader('content-type', 'application/json');
@@ -301,16 +263,6 @@ public function testRestRenderCaching() {
     $this->assertCacheTags($cache_tags);
     $this->assertTrue($render_cache->get($original));
 
-    $result_xml = $this->drupalGetWithFormat('test/serialize/entity', 'xml');
-    $this->addRequestWithFormat('xml');
-    $this->assertHeader('content-type', 'text/xml; charset=UTF-8');
-    $this->assertCacheContexts($cache_contexts);
-    $this->assertCacheTags($cache_tags);
-    $this->assertTrue($render_cache->get($original));
-
-    // Ensure that the XML output is different from the JSON one.
-    $this->assertNotEqual($result1, $result_xml);
-
     // Ensure that the cached page works.
     $result2 = $this->drupalGetJSON('test/serialize/entity');
     $this->addRequestWithFormat('json');
@@ -345,21 +297,21 @@ public function testResponseFormatConfiguration() {
 
     $style_options = 'admin/structure/views/nojs/display/test_serializer_display_field/rest_export_1/style_options';
 
-    // Select only 'xml' as an accepted format.
-    $this->drupalPostForm($style_options, array('style_options[formats][xml]' => 'xml'), t('Apply'));
+    // Select only 'json' as an accepted format.
+    $this->drupalPostForm($style_options, array('style_options[formats][json]' => 'json'), t('Apply'));
     $this->drupalPostForm(NULL, array(), t('Save'));
 
     // Should return a 406.
-    $this->drupalGetWithFormat('test/serialize/field', 'json');
+    $this->drupalGetWithFormat('test/serialize/field', 'hal_json');
     $this->assertHeader('content-type', 'application/json');
-    $this->assertResponse(406, 'A 406 response was returned when JSON was requested.');
+    $this->assertResponse(406, 'A 406 response was returned when HAL+JSON was requested.');
     // Should return a 200.
-    $this->drupalGetWithFormat('test/serialize/field', 'xml');
-    $this->assertHeader('content-type', 'text/xml; charset=UTF-8');
-    $this->assertResponse(200, 'A 200 response was returned when XML was requested.');
+    $this->drupalGetWithFormat('test/serialize/field', 'json');
+    $this->assertHeader('content-type', 'application/json');
+    $this->assertResponse(200, 'A 200 response was returned when JSON was requested.');
 
-    // Add 'json' as an accepted format, so we have multiple.
-    $this->drupalPostForm($style_options, array('style_options[formats][json]' => 'json'), t('Apply'));
+    // Add 'hal_json' as an accepted format, so we have multiple.
+    $this->drupalPostForm($style_options, array('style_options[formats][hal_json]' => 'hal_json'), t('Apply'));
     $this->drupalPostForm(NULL, array(), t('Save'));
 
     // Should return a 200.
@@ -368,23 +320,18 @@ public function testResponseFormatConfiguration() {
     $this->assertHeader('content-type', 'application/json');
     $this->assertResponse(200, 'A 200 response was returned when any format was requested.');
 
-    // Should return a 200. Emulates a sample Firefox header.
-    $this->drupalGet('test/serialize/field', array(), array('Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'));
-    $this->assertHeader('content-type', 'application/json');
-    $this->assertResponse(200, 'A 200 response was returned when a browser accept header was requested.');
-
     // Should return a 200.
-    $this->drupalGetWithFormat('test/serialize/field', 'json');
-    $this->assertHeader('content-type', 'application/json');
-    $this->assertResponse(200, 'A 200 response was returned when JSON was requested.');
+    $this->drupalGetWithFormat('test/serialize/field', 'hal_json');
+    $this->assertHeader('content-type', 'application/hal+json');
+    $this->assertResponse(200, 'A 200 response was returned when HAL+JSON was requested.');
     $headers = $this->drupalGetHeaders();
-    $this->assertEqual($headers['content-type'], 'application/json', 'The header Content-type is correct.');
+    $this->assertEqual($headers['content-type'], 'application/hal+json', 'The header Content-type is correct.');
     // Should return a 200.
-    $this->drupalGetWithFormat('test/serialize/field', 'xml');
-    $this->assertHeader('content-type', 'text/xml; charset=UTF-8');
-    $this->assertResponse(200, 'A 200 response was returned when XML was requested');
+    $this->drupalGetWithFormat('test/serialize/field', 'json');
+    $this->assertHeader('content-type', 'application/json');
+    $this->assertResponse(200, 'A 200 response was returned when JSON was requested');
     $headers = $this->drupalGetHeaders();
-    $this->assertTrue(strpos($headers['content-type'], 'text/xml') !== FALSE, 'The header Content-type is correct.');
+    $this->assertTrue($headers['content-type'], 'application/json', 'The header Content-type is correct.');
     // Should return a 406.
     $this->drupalGetWithFormat('test/serialize/field', 'html');
     // We want to show the first format by default, see
@@ -392,17 +339,17 @@ public function testResponseFormatConfiguration() {
     $this->assertHeader('content-type', 'application/json');
     $this->assertResponse(200, 'A 200 response was returned when HTML was requested.');
 
-    // Now configure now format, so all of them should be allowed.
-    $this->drupalPostForm($style_options, array('style_options[formats][json]' => '0', 'style_options[formats][xml]' => '0'), t('Apply'));
+    // Now configure no format, so all of them should be allowed.
+    $this->drupalPostForm($style_options, array('style_options[formats][json]' => '0', 'style_options[formats][hal_json]' => '0'), t('Apply'));
 
     // Should return a 200.
     $this->drupalGetWithFormat('test/serialize/field', 'json');
     $this->assertHeader('content-type', 'application/json');
     $this->assertResponse(200, 'A 200 response was returned when JSON was requested.');
     // Should return a 200.
-    $this->drupalGetWithFormat('test/serialize/field', 'xml');
-    $this->assertHeader('content-type', 'text/xml; charset=UTF-8');
-    $this->assertResponse(200, 'A 200 response was returned when XML was requested');
+    $this->drupalGetWithFormat('test/serialize/field', 'hal_json');
+    $this->assertHeader('content-type', 'application/hal+json');
+    $this->assertResponse(200, 'A 200 response was returned when HAL+JSON was requested');
     // Should return a 200.
     $this->drupalGetWithFormat('test/serialize/field', 'html');
     // We want to show the first format by default, see
@@ -575,25 +522,6 @@ public function testLivePreview() {
     $rendered_json = $build['#plain_text'];
     $this->assertTrue(!isset($build['#markup']) && $rendered_json == $expected, 'Ensure the previewed json is escaped.');
     $view->destroy();
-
-    $expected = $serializer->serialize($entities, 'xml');
-
-    // Change the request format to xml.
-    $view->setDisplay('rest_export_1');
-    $view->getDisplay()->setOption('style', array(
-      'type' => 'serializer',
-      'options' => array(
-        'uses_fields' => FALSE,
-        'formats' => array(
-          'xml' => 'xml',
-        ),
-      ),
-    ));
-
-    $this->executeView($view);
-    $build = $view->preview();
-    $rendered_xml = $build['#plain_text'];
-    $this->assertEqual($rendered_xml, $expected, 'Ensure we preview xml when we change the request format.');
   }
 
   /**
diff --git a/core/modules/rest/tests/modules/rest_test/rest_test.services.yml b/core/modules/rest/tests/modules/rest_test/rest_test.services.yml
new file mode 100644
index 0000000..87e47e8
--- /dev/null
+++ b/core/modules/rest/tests/modules/rest_test/rest_test.services.yml
@@ -0,0 +1,5 @@
+services:
+  serializer.encoder.foobar:
+    class: Drupal\serialization\Encoder\JsonEncoder
+    tags:
+      - { name: encoder, format: foobar }
diff --git a/core/modules/rest/tests/modules/rest_test/src/RestTestServiceProvider.php b/core/modules/rest/tests/modules/rest_test/src/RestTestServiceProvider.php
new file mode 100644
index 0000000..7d3aeb4
--- /dev/null
+++ b/core/modules/rest/tests/modules/rest_test/src/RestTestServiceProvider.php
@@ -0,0 +1,22 @@
+<?php
+
+namespace Drupal\rest_test;
+
+use Drupal\Core\DependencyInjection\ContainerBuilder;
+use Drupal\Core\DependencyInjection\ServiceModifierInterface;
+
+/**
+ * Adds "foobar" as known format.
+ */
+class RestTestServiceProvider implements ServiceModifierInterface {
+
+  /**
+   * {@inheritdoc}
+   */
+  public function alter(ContainerBuilder $container) {
+    if ($container->has('http_middleware.negotiation') && is_a($container->getDefinition('http_middleware.negotiation')->getClass(), '\Drupal\Core\StackMiddleware\NegotiationMiddleware', TRUE)) {
+      $container->getDefinition('http_middleware.negotiation')->addMethodCall('registerFormat', ['foobar', ['text/foobar']]);
+    }
+  }
+
+}
diff --git a/core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php b/core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php
index 973f5b9..f2ed502 100644
--- a/core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php
+++ b/core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php
@@ -601,7 +601,7 @@ public function testPost() {
     $this->assertAuthenticationEdgeCases('POST', $url, $request_options);
 
 
-    $request_options[RequestOptions::HEADERS]['Content-Type'] = 'text/xml';
+    $request_options[RequestOptions::HEADERS]['Content-Type'] = 'text/foobar';
 
 
     // DX: 415 when request body in existing but not allowed format.
@@ -809,7 +809,7 @@ public function testPatch() {
     $this->assertAuthenticationEdgeCases('PATCH', $url, $request_options);
 
 
-    $request_options[RequestOptions::HEADERS]['Content-Type'] = 'text/xml';
+    $request_options[RequestOptions::HEADERS]['Content-Type'] = 'text/foobar';
 
 
     // DX: 415 when request body in existing but not allowed format.
diff --git a/core/modules/serialization/serialization.info.yml b/core/modules/serialization/serialization.info.yml
index 7c4eb52..9e59558 100644
--- a/core/modules/serialization/serialization.info.yml
+++ b/core/modules/serialization/serialization.info.yml
@@ -1,6 +1,6 @@
 name: Serialization
 type: module
-description: Provides a service for (de)serializing data to/from formats such as JSON and XML
+description: Provides a service for (de)serializing data to/from formats such as JSON
 package: Web services
 version: VERSION
 core: 8.x
diff --git a/core/modules/serialization/serialization.module b/core/modules/serialization/serialization.module
index 39c5fbf..b593ee9 100644
--- a/core/modules/serialization/serialization.module
+++ b/core/modules/serialization/serialization.module
@@ -2,7 +2,7 @@
 
 /**
  * @file
- * Provides a service for (de)serializing data to/from formats such as JSON and XML.
+ * Provides a service for (de)serializing data to/from formats such as JSON.
  */
 
 use Drupal\Core\Routing\RouteMatchInterface;
@@ -15,7 +15,7 @@ function serialization_help($route_name, RouteMatchInterface $route_match) {
     case 'help.page.serialization':
       $output = '';
       $output .= '<h3>' . t('About') . '</h3>';
-      $output .= '<p>' . t('The Serialization module provides a service for serializing and deserializing data to and from formats such as JSON and XML.') . '</p>';
+      $output .= '<p>' . t('The Serialization module provides a service for serializing and deserializing data to and from formats such as JSON.') . '</p>';
       $output .= '<p>' . t('Serialization is the process of converting data structures like arrays and objects into a string. This allows the data to be represented in a way that is easy to exchange and store (for example, for transmission over the Internet or for storage in a local file system). These representations can then be deserialized to get back to the original data structures.') . '</p>';
       $output .= '<p>' . t('The serializer splits this process into two parts. Normalization converts an object to a normalized array structure. Encoding takes that array and converts it to a string.') . '</p>';
       $output .= '<p>' . t('This module does not have a user interface. It is used by other modules which need to serialize data, such as <a href=":rest">REST</a>.', array(':rest' => (\Drupal::moduleHandler()->moduleExists('rest')) ? \Drupal::url('help.page', array('name' => 'rest')) : '#')) . '</p>';
diff --git a/core/modules/serialization/serialization.services.yml b/core/modules/serialization/serialization.services.yml
index 8b570c0..7436a50 100644
--- a/core/modules/serialization/serialization.services.yml
+++ b/core/modules/serialization/serialization.services.yml
@@ -49,10 +49,6 @@ services:
     class: Drupal\serialization\Encoder\JsonEncoder
     tags:
       - { name: encoder, format: json }
-  serializer.encoder.xml:
-    class: Drupal\serialization\Encoder\XmlEncoder
-    tags:
-      - { name: encoder, format: xml }
   serializer.entity_resolver:
     class: Drupal\serialization\EntityResolver\ChainEntityResolver
   serializer.entity_resolver.uuid:
diff --git a/core/modules/serialization/src/Encoder/XmlEncoder.php b/core/modules/serialization/src/Encoder/XmlEncoder.php
index abd7896..f5456d4 100644
--- a/core/modules/serialization/src/Encoder/XmlEncoder.php
+++ b/core/modules/serialization/src/Encoder/XmlEncoder.php
@@ -11,6 +11,9 @@
  *
  * This acts as a wrapper class for Symfony's XmlEncoder so that it is not
  * implementing NormalizationAwareInterface, and can be normalized externally.
+ *
+ * @deprecated in Drupal 8.3.x and will be removed before Drupal 9.0.0. This
+ *   exists solely for BC, for classes extending this.
  */
 class XmlEncoder implements EncoderInterface, DecoderInterface {
 
diff --git a/core/modules/serialization/tests/src/Kernel/EntitySerializationTest.php b/core/modules/serialization/tests/src/Kernel/EntitySerializationTest.php
index 0f84d3d..15f0937 100644
--- a/core/modules/serialization/tests/src/Kernel/EntitySerializationTest.php
+++ b/core/modules/serialization/tests/src/Kernel/EntitySerializationTest.php
@@ -178,34 +178,6 @@ public function testSerialize() {
     $this->assertIdentical($actual, $expected, 'Entity serializes to JSON when "ajax" is requested.');
     $actual = $this->serializer->serialize($normalized, 'ajax');
     $this->assertIdentical($actual, $expected, 'A normalized array serializes to JSON when "ajax" is requested');
-
-    // Generate the expected xml in a way that allows changes to entity property
-    // order.
-    $expected = array(
-      'id' => '<id><value>' . $this->entity->id() . '</value></id>',
-      'uuid' => '<uuid><value>' . $this->entity->uuid() . '</value></uuid>',
-      'langcode' => '<langcode><value>en</value></langcode>',
-      'name' => '<name><value>' . $this->values['name'] . '</value></name>',
-      'type' => '<type><value>entity_test_mulrev</value></type>',
-      'created' => '<created><value>' . $this->entity->created->value . '</value></created>',
-      'user_id' => '<user_id><target_id>' . $this->user->id() . '</target_id><target_type>' . $this->user->getEntityTypeId() . '</target_type><target_uuid>' . $this->user->uuid() . '</target_uuid><url>' . $this->user->url() . '</url></user_id>',
-      'revision_id' => '<revision_id><value>' . $this->entity->getRevisionId() . '</value></revision_id>',
-      'default_langcode' => '<default_langcode><value>1</value></default_langcode>',
-      'non_rev_field' => '<non_rev_field/>',
-      'field_test_text' => '<field_test_text><value>' . $this->values['field_test_text']['value'] . '</value><format>' . $this->values['field_test_text']['format'] . '</format></field_test_text>',
-    );
-    // Sort it in the same order as normalised.
-    $expected = array_merge($normalized, $expected);
-    // Add header and footer.
-    array_unshift($expected, '<?xml version="1.0"?>' . PHP_EOL . '<response>');
-    $expected[] = '</response>' . PHP_EOL;
-    // Reduced the array to a string.
-    $expected = implode('', $expected);
-    // Test 'xml'. The output should match that of Symfony's XmlEncoder.
-    $actual = $this->serializer->serialize($this->entity, 'xml');
-    $this->assertIdentical($actual, $expected);
-    $actual = $this->serializer->serialize($normalized, 'xml');
-    $this->assertIdentical($actual, $expected);
   }
 
   /**
@@ -214,7 +186,7 @@ public function testSerialize() {
   public function testDenormalize() {
     $normalized = $this->serializer->normalize($this->entity);
 
-    foreach (array('json', 'xml') as $type) {
+    foreach (array('json') as $type) {
       $denormalized = $this->serializer->denormalize($normalized, $this->entityClass, $type, array('entity_type' => 'entity_test_mulrev'));
       $this->assertTrue($denormalized instanceof $this->entityClass, SafeMarkup::format('Denormalized entity is an instance of @class', array('@class' => $this->entityClass)));
       $this->assertIdentical($denormalized->getEntityTypeId(), $this->entity->getEntityTypeId(), 'Expected entity type found.');
diff --git a/core/modules/serialization/tests/src/Unit/Encoder/XmlEncoderTest.php b/core/modules/serialization/tests/src/Unit/Encoder/XmlEncoderTest.php
deleted file mode 100644
index ea38aa9..0000000
--- a/core/modules/serialization/tests/src/Unit/Encoder/XmlEncoderTest.php
+++ /dev/null
@@ -1,79 +0,0 @@
-<?php
-
-namespace Drupal\Tests\serialization\Unit\Encoder;
-
-use Drupal\serialization\Encoder\XmlEncoder;
-use Drupal\Tests\UnitTestCase;
-
-/**
- * @coversDefaultClass \Drupal\serialization\Encoder\XmlEncoder
- * @group serialization
- */
-class XmlEncoderTest extends UnitTestCase {
-
-  /**
-   * The XmlEncoder instance.
-   *
-   * @var \Drupal\serialization\Encoder\XmlEncoder
-   */
-  protected $encoder;
-
-  /**
-   * @var \Symfony\Component\Serializer\Encoder\XmlEncoder|\PHPUnit_Framework_MockObject_MockObject
-   */
-  protected $baseEncoder;
-
-  /**
-   * An array of test data.
-   *
-   * @var array
-   */
-  protected $testArray = array('test' => 'test');
-
-  protected function setUp() {
-    $this->baseEncoder = $this->getMock('Symfony\Component\Serializer\Encoder\XmlEncoder');
-    $this->encoder = new XmlEncoder();
-    $this->encoder->setBaseEncoder($this->baseEncoder);
-  }
-
-  /**
-   * Tests the supportsEncoding() method.
-   */
-  public function testSupportsEncoding() {
-    $this->assertTrue($this->encoder->supportsEncoding('xml'));
-    $this->assertFalse($this->encoder->supportsEncoding('json'));
-  }
-
-  /**
-   * Tests the supportsDecoding() method.
-   */
-  public function testSupportsDecoding() {
-    $this->assertTrue($this->encoder->supportsDecoding('xml'));
-    $this->assertFalse($this->encoder->supportsDecoding('json'));
-  }
-
-  /**
-   * Tests the encode() method.
-   */
-  public function testEncode() {
-    $this->baseEncoder->expects($this->once())
-      ->method('encode')
-      ->with($this->testArray, 'test', array())
-      ->will($this->returnValue('test'));
-
-    $this->assertEquals('test', $this->encoder->encode($this->testArray, 'test'));
-  }
-
-  /**
-   * Tests the decode() method.
-   */
-  public function testDecode() {
-    $this->baseEncoder->expects($this->once())
-      ->method('decode')
-      ->with('test', 'test', array())
-      ->will($this->returnValue($this->testArray));
-
-    $this->assertEquals($this->testArray, $this->encoder->decode('test', 'test'));
-  }
-
-}
diff --git a/core/modules/user/tests/src/Functional/UserLoginHttpTest.php b/core/modules/user/tests/src/Functional/UserLoginHttpTest.php
index 29b9727..5616f90 100644
--- a/core/modules/user/tests/src/Functional/UserLoginHttpTest.php
+++ b/core/modules/user/tests/src/Functional/UserLoginHttpTest.php
@@ -9,7 +9,6 @@
 use GuzzleHttp\Cookie\CookieJar;
 use Psr\Http\Message\ResponseInterface;
 use Symfony\Component\Serializer\Encoder\JsonEncoder;
-use Symfony\Component\Serializer\Encoder\XmlEncoder;
 use Drupal\hal\Encoder\JsonEncoder as HALJsonEncoder;
 use Symfony\Component\Serializer\Serializer;
 
@@ -47,7 +46,7 @@ class UserLoginHttpTest extends BrowserTestBase {
   protected function setUp() {
     parent::setUp();
     $this->cookies = new CookieJar();
-    $encoders = [new JsonEncoder(), new XmlEncoder(), new HALJsonEncoder()];
+    $encoders = [new JsonEncoder(), new HALJsonEncoder()];
     $this->serializer = new Serializer([], $encoders);
   }
 
@@ -98,7 +97,7 @@ public function testLogin() {
         /** @var \Drupal\Core\Extension\ModuleInstaller $module_installer */
         $module_installer = $this->container->get('module_installer');
         $module_installer->install(['serialization']);
-        $formats = ['json', 'xml', 'hal_json'];
+        $formats = ['json', 'hal_json'];
       }
       else {
         // Without the serialization module only JSON is supported.
