1 Cimb answered Jul 1 '21 00:00 use XMLReader , as per below code : $reader = new XMLReader(); $reader->open('sitemap.xml'); $count=0; while ($reader->read()) { if($reader->name=='url'){ $count++; } } echo $count; above code is read sitemap.xml and give count of the url elements Edit Answer