New to our community ?

Discover a world of possibilities! Join us and explore a vibrant community where ideas flourish and connections thrive.

One of Our Valued Members

Thank you for being part of our community. Your presence enriches our shared experiences. Let's continue this journey together!

Home php codes Read xml file using php

Read xml file using php


In this post we will see how to read an xml file with the help of php function.

read xml file using php

most of the time we need to fetch records from xml file, so we use a php function
The simplexml_load_file() function which helps to converts the specified XML file into
a SimpleXMLElement object.


here we have xml file which is named as sitemap.xml, we fetch  all dates from sitemap using simplexml_load_file() function.

in fetch.php file we fetch all records from sitemap.xml file.

$xml = simple_load_file('sitemap.xml');
foreach($xml->children() as $data)
echo $data->to."<br>";
echo $data->from."<br>";
echo $data->heading."<br>";
echo $data->body."<br>";