Create Dynamic XML using php
Posted in: PHP

Create Dynamic XML Using PHP Part -2 | Create List and Delete Entry

Click here for create dynamic XML using PHP part 1. Now this is part 2 in this tutorial i will show you how you can list and delete the xml data from your page. In the previous tutorial we have created the XML file with our form.

Listing the XML values to our page is easy and use very less code.

In the previous tutorial we have created a class – autoAssignerClass.php where we are writing our functions.Now we will add one more function that is listing the saved XML values in array.

In the above code you can see we have used the simplexml to load the saved xml file. After getting the file we convert it to JSON so that it will be easy for us to use it in our PHP page. After the json encode we decoded the JSON and received the values in array. Finally after the checking our function will return the array.

For using this function we will include the class and create the object of the class to use its functions to our page where we want to show the list. You can see the previous tutorial where we have already created the object of the class. We call our function and get the list.

We use table to show the list which we get from XML.

After showing the list we need to delete the entry also. For this we have created the delete function.

For triggering delete function we use javascript. To ask Yes and no

If user clicks on Yes it will call the delete method and delete the particular entry.

autoAssignerClass.php

Full autoassignerclass.

Hope you like the tutorial – Create dynamic XML using php part -2 if you find any issue or having any advice then please comment below. Please share it with your friends.

 

Leave a Reply

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