PHP - From DOMDocument to XMLReader
<p>PHP developers here ??
I have a PHP function who parse an xml file (using DOMDocument, i'm proficien with this tool). I want to do the same with XMLReader, but i don't understand how XMLReader works...</p>

<p>I want to use XMLReader because it's a light tool.</p>

<p>Feel free to ask me others questions about my issue. </p>

<pre><code>function getDatas($filepath)
{
    $doc = new DOMDocument();
    $xmlfile = file_get_contents($filepath);
    $doc-&gt;loadXML($xmlfile);

    $xmlcars = $doc-&gt;getElementsByTagName('car');
    $mycars= [];

    foreach ($xmlcars as $xmlcar) {
        $car = new Car();
        $car-&gt;setName(
            $xmlcar-&gt;getElementsByTagName('id')-&gt;item(0)-&gt;nodeValue
        );
        $car-&gt;setBrand(
            $xmlcar-&gt;getElementsByTagName('brand')-&gt;item(0)-&gt;nodeValue
        );

        array_push($mycars, $car);
    }
    return $mycars;

 }
</code></pre>

<p>PS : I'm not a senior PHP dev. </p>

<p>Ahah Thanks.</p>