<?php
use Symfony\Component\Config\Util\XmlUtils;
$file = __DIR__.'/city.xml';
echo 'file content:';
dump(file_get_contents($file));
/* @var $dom \DOMDocument */
$dom = XmlUtils::loadFile($file);
$city = $dom->getElementsByTagName('City')
->item(0);
echo get_class($city);
dump(
XmlUtils::convertDomElementToArray($city)
);
^ """ <?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> """DOMElement
^ array:2 [ "CityId" => 1 "Name" => "South Park" ]