How can I remove all comments from a large XML file?
I have a large file XML and I want to thin it and I want to remove all the comments. The file has a size of over 200 mb and it takes a lot to parse the file and query something.
Code for parse is :
<?php
$dom = new DOMDocument();
$xpath = new DOMXPath($dom);
$reader = new XMLReader();
$reader->open('http://www.bookingassist.ro/test/HotelsPro.xml');
while ($reader->read()) {
if ($reader->nodeType == XMLReader::ELEMENT && $reader->name == 'Hotel') {
$node = $dom->importNode($reader->expand(), true);
$dom->appendChild($node);
$result = $xpath->evaluate('string(self::Hotel[HotelCode = "'.$hotelCodes[3].'"]/HotelImages/ImageURL[1])', $node);
$dom->removeChild($node);
if ($result) {
echo $result;
}
}
}
?>