What potential issues can arise when using file_get_contents or fread to read XML files in PHP?

When using file_get_contents or fread to read XML files in PHP, potential issues can arise with handling large files as they are read into memory all at once, which can lead to memory exhaustion. To solve this issue, it's recommended to use XMLReader, which allows for parsing XML files in a stream-oriented manner, reducing memory consumption.

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

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

$reader->close();