How to Generate XML file Dynamically in PHP and Mysql

This tutorial will help you to generate XML file dynamically using PHP and MySql. Xml data can be simple to maintain and quite easy to integrate with flash environment.

In this article i’ll explain you how to execute Mysql query and format the data into an XML format than save it on server.

Steps to Generate an XML file from Mysql database.

Step 1: Declare the header content type as text/xml

header(‘Content-Type: text/xml; charset=utf-8’);

Step 2: Make an Database connection.

Step 3: Write the xml code to generate xml data.

After execute this code, you will get the response as xml format and data will save on your server as save.xml file.

Note :- If you are using an http url as string in xml data with & symbol in between. It will give an error to string can not be parsed. Use & instead of & symbol in xml data.

Using above steps you can easily generate and save an xml file from Mysql data.

Recommended Posts For You

About Harish

I am professional web developer and blogger. Use this blog to share own api and other web development experience with you. I do accept paid work. Write to me at - [email protected]

View all posts by Harish

Leave a Comment

Your email address will not be published. Required fields are marked *