I am using the below code in PHP to parse a XML file and retrieve a certain information from the file.
$dom    = new DOMDocument();
$xpath  = new DOMXPath($dom);
$reader = new XMLReader();
$reader->open('File.xml');
while ($reader->read()) {
    if ($reader->nodeType == XMLReader::ELEMENT && $reader->name == 'Hotel') {
        $node = $dom->importNode($reader->expand(), true);
        $dom->appendChild($node);
        $h1name = $xpath->evaluate('string(/Hotel[HotelCode = "'.$hotelCodes[0].'"]/HotelName)', $node);
        $dom->removeChild($node);
        if ($h1name) {
         $reader->close();
         break;
        }
    }
}
I am using a VPS with CENTOS x64 , SSD drive, 1GB of ram and a 1.8 ghz CPU. The code works but is very slow. If i parse a 20 mb file it takes ~1 minute fo the page to load.
Could you please help to improve the code so i can get a faster working solution ?