Jump to content

Replace database contents with xml file


hcanning2012

Recommended Posts

Hi Guys,

new to php so wondering how to automatically import an xml file into my mysql db and overwriting the contents.

Say I have a db called db1 and table called table1 with fields 'first name' and 'last name'. Lets say I export the db as xml, empty the tables and and want to repopulate the db with the exported xml file using a php file specifically?

How would I do that? Not having success with https://stackoverflow.com/questions/5491056/how-to-import-xml-file-into-mysql-database-table-using-xml-load-function

Thought someone may know a sample using a db config file connection to a mysql db?

Thanks

Link to comment
Share on other sites

There isn't an automated process because there is no sort of official database dump schema for XML. You have to write code to load the XML, loop over it as needed, and execute whatever queries you have to.

 

If you need help with that then you need to post what code you have and an explanation of what is not working.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.