diff --git a/src/Plugin/migrate_plus/data_parser/Xml.php b/src/Plugin/migrate_plus/data_parser/Xml.php
index 7ec22a6988e2778780c814a5ea769f7f86a679c3..47165bdc5236fa2ed9819f8e7c7abe6576f81e02 100644
--- a/src/Plugin/migrate_plus/data_parser/Xml.php
+++ b/src/Plugin/migrate_plus/data_parser/Xml.php
@@ -87,6 +87,13 @@ class Xml extends DataParserPluginBase implements ContainerFactoryPluginInterfac
    */
   protected bool $prefixedName = FALSE;
 
+  /**
+   * Temporary file name of file that holds XML.
+   *
+   * @var string|null
+   */
+  protected ?string $tempFileName;
+
   /**
    * Constructs a new XML data parser.
    *
@@ -201,8 +208,8 @@ class Xml extends DataParserPluginBase implements ContainerFactoryPluginInterfac
 
     // Fetch the data and save it to a temporary file.
     $xml_data = $this->getDataFetcherPlugin()->getResponseContent($url);
-    $url = $this->fileSystem->tempnam('temporary://', 'file');
-    if (file_put_contents($url, $xml_data) === FALSE) {
+    $this->tempFileName = $this->fileSystem->tempnam('temporary://', 'file');
+    if (file_put_contents($this->tempFileName, $xml_data) === FALSE) {
       throw new MigrateException('Unable to save temporary XML');
     }
 
@@ -212,7 +219,15 @@ class Xml extends DataParserPluginBase implements ContainerFactoryPluginInterfac
     // that occur from attempting to load the XML string into an object here.
     libxml_clear_errors();
 
-    return $this->reader->open($url, NULL, \LIBXML_NOWARNING);
+    return $this->reader->open($this->tempFileName, NULL, \LIBXML_NOWARNING);
+  }
+
+  protected function nextSource(): bool {
+    $valid_source = parent::nextSource();
+    if (isset($this->tempFileName) && file_exists($this->tempFileName)) {
+      unlink($this->tempFileName);
+    }
+    return $valid_source;
   }
 
   /**