Hello everyone!

We have been investing plenty of personal time and energy for many years to share our knowledge with you all. However, we now need your help to keep this blog running. All you have to do is just click one of the adverts on the site, otherwise it will sadly be taken down due to hosting etc. costs. Thank you.

You can use example to read XML files.

XML file

<?xml version="1.0"?>
<ad_date>2018-10-17 6:59:59 pm</ad_date>

XML reader


namespace AppBundle\Util\XMLParser;

use SimpleXMLElement;
use XMLReader;

class XMLParser
public function parse(string $filePath, string $rootNode): void
$XMLReader = new XMLReader();

while ($XMLReader->read()) {
if ($rootNode === $XMLReader->name && XMLReader::END_ELEMENT !== $XMLReader->nodeType) {
$property = new SimpleXMLElement($XMLReader->readOuterXML());

echo $property->asXML();



$parser = new XMLParser();
$parser->parse('property.xml', 'property');