What are the potential pitfalls of using XMLReader in PHP for parsing large XML files?

Potential pitfalls of using XMLReader in PHP for parsing large XML files include memory consumption and performance issues. To mitigate these problems, it is recommended to use XMLReader in a streaming fashion, processing the XML file node by node without loading the entire document into memory at once.

$reader = new XMLReader();
$reader->open('large_file.xml');

while ($reader->read()) {
    // Process each node here
}

$reader->close();