Changing XML data to Yaml with XSLT template

Code
<?php

$xslStr 
'<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:variable name="nl"><xsl:text>
</xsl:text></xsl:variable>

<xsl:template xml:space="default" match="/">
    <xsl:text>cities:</xsl:text>
    <xsl:value-of select="$nl"/>
    <xsl:for-each select="List/City">
      <xsl:value-of select="concat(\'  id\', CityId)"/>: <xsl:value-of select="Name" />
      <xsl:value-of select="$nl"/>
    </xsl:for-each>
</xsl:template>

<xsl:output method="text" media-type="text/yml" />

</xsl:stylesheet>'
;

$xsl = new DOMDocument();
$xsl->loadXML($xslStr);

$xml = new DOMDocument();
$xml->load(__DIR__ '/city.xml');

$p = new XSLTProcessor();
$p->importStylesheet($xsl);

$xml $p->transformToXML($xml);

echo 
'<pre>' $xml '</pre>';
Result
cities:
  id1: South Park
  id2: Springfield
  id3: Quahog
Used Versions
PHP 8.2, Laminas MVC 3.2, Symfony 5.2, Laravel 8.28, PHPUnit 9.5, Doctrine ORM 2.8