What are the potential pitfalls in using DOMDocument to parse XML files in PHP?

One potential pitfall in using DOMDocument to parse XML files in PHP is that it may consume a large amount of memory when dealing with large XML files, leading to performance issues or even script timeouts. To mitigate this, you can use the `XMLReader` class, which provides a more memory-efficient way to parse XML files in a streaming fashion.

$xmlReader = new XMLReader();
$xmlReader->open('example.xml');

while ($xmlReader->read()) {
    // process XML nodes here
}

$xmlReader->close();