Create Dynamic XML using PHP
Posted in: PHP

Create Dynamic XML Using PHP Part -1 | Create Dropdown Using XML

Create Dynamic XML using PHP is our new topic, Hello friends, this time i came up with interesting dynamic use of xml instead of Database. Many times we need to save some values and we do not need to play with database features. This XML facility can help you to make things dynamic like: Website Slider, Saving form values, Crating dynamic dropdown box etc. These are fast to use as you dont have to connect to the database.




In this tutorial i will just create the xml and save the values to the xml. In next we will check the duplicate entry and delete the entry. So lets start……

If you are interested in creating dropdown based image uploaded click here to check it out

First of all we will create a form through which we will receive our values. So lets start our form building.

This form is related to saving sms templates for which we are going to use in our application.  After submit it will give 2 values 1. Name of Sms 2. Content of SMS. After the submit we will send our values to our is_set function.

is_set function

In the above code i am not using any kind of filtration or checking of the values so if you are using the code then please do that so you wont be in trouble. Now you have have the values and as you can see i am using a function getXmlDetails with 2 parameters 1 will have your form values and 2nd will have the file name this function belongs to the autoAssignerClass. After getting the values we will submit the values to our xml file using our class.

autoAssignerClass.php

In the above code you can see that we are using 3 functions. First function getXmlDetails() will have your values which is coming from the form. Now this function will call the next function based upon the details. If its first time and your xml file is not created then it will call the createFirstTimeXML() function with details. Now if we have already added the first entry or created the xml then our updateEntryToXML() function will run.




If you are posting the same type of sms then will give you the error of “already exists” otherwise it will just update the xml node to the already created xml. Use this code and create dynamic xml using php

In the next tutorial you will see the Listing of data stored and deletion of data stored. Hope you will like the tutorial please share it and use the code if you face any issue then please comment.

Leave a Reply

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