Convert xml file into excel file using php


Here we are describing convert xml file into excel file using php.Simple way to convert xml file into excel file with php.If you have basic knowledge of xml and php(:D) this is very easy.My another post is showing how to read Excel file and save details to database using php. If you not good familiar with xml read this PHP Creating XML file post and Read XML file using PHP post to get and better idea.

Okay.First you need to create you xml file. I’ll show you my xml file format for a example.

		Miguel Alvarez
		Vijay Joshi
		Reilly Media
		WIlliam Vega

How to read this xml file?

    $url = 'Library.xml'; // xml file location with file name
if (file_exists($url)) {
    $xml = simplexml_load_file($url);

How to convert xml file into excel file?

book as $books)
		echo $books->title."\t" . $books->author."\t" . $books->publisher."\t" . $books->price."\n";

That’s only.
Remember this is simple example to show how to convert xml file into excel file using php.
Here is the full source code to download.

[like-to-dl theme=”blue” url=”” like_url=”” message=”Click Like to Start Download full source code(2 KiB)”]


About Author

Sumith Harshan is the Managing Director of the WebXtreams(Pvt) Ltd in Sri lanka.Specializes in Java Script, JQuery, HTML4/5, CSS2/3, PHP, CodeIgniter, CakePHP, J2SE, J2EE, XML, Hacking & Security, Mobile Interface Developing, Magento, Wordpress, Joomla, Drupal and PHPBB.

  • Vignesh Waran

    you are awesome …thanks working great, and i need excel to xml using php.thanks