code: private function getDocumentStream($xmlDocument)
      {
          /**
           * @var StreamAdapterInterface $streamAdapter
           */
          foreach ($this->streamAdapters as $streamAdapter) {
  
              if ($streamAdapter->supports($xmlDocument)) {
                  return $streamAdapter->convert($xmlDocument);
              }
          }
  
          throw new RuntimeException(sprintf('Suitable XML document stream adapter is not registered for XML document of type "%s".', is_object($xmlDocument) ? get_class($xmlDocument) : gettype($xmlDocument)));
      }
docs: Convert XML document to stream source.
  
  @param mixed $xmlDocument XML document source.
  @return StreamInterface Converted XML document to stream.
  
  @throws \RuntimeException