Convert XML to Json in Laminas

Code
<?php

use Laminas\Xml2Json\Xml2Json;

$xmlStr file_get_contents(__DIR__ '/city.xml');

$json Xml2Json::fromXml($xmlStr);

echo 
dump($xmlStr);
echo 
$json;
Result
^ """
<?xml version="1.0" encoding="UTF-8"?>\n
<List>\n
<City>\n
<CityId>1</CityId>\n
<Name>South Park</Name>\n
</City>\n
<City>\n
<CityId>2</CityId>\n
<Name>Springfield</Name>\n
</City>\n
<City>\n
<CityId>3</CityId>\n
<Name>Quahog</Name>\n
</City>\n
</List>
"""




1
South Park


2
Springfield


3
Quahog

{"List":{"City":[{"CityId":"1","Name":"South Park"},{"CityId":"2","Name":"Springfield"},{"CityId":"3","Name":"Quahog"}]}}
Used Versions
PHP 8.0, Laminas MVC 3.2, Symfony 5.2, Laravel 8.28, PHPUnit 9.5, Doctrine ORM 2.8