How to create dynamic sitemap.xml in codeigniter

You just need to create below function in your controller. And what data you want to insert in xml file please add as per your requirement, you can save all the data in database and fatch in this function.

If you will call that function by browser, sitemap.xml automatically will generate on root folder if sitemap.xml already created then that function call will overwrite it.