I have a dynamic products xml file that i need to load from an external source and save in a db table. Now i want to keep the xml file which contains current products in synch with what is in the table. so I want to make sure I update products with IDs in both xml and db table, insert new products and delete those products that are obsolete in db table (they are not in xml file) see illustrations below
XML file mapping
Productid->1 and product-name->book,
Productid->2 and Prouct-name->pen
Now table below
ID Name
1 book
3 pencil
Now I want to update product ID 1 with info from xml, insert product ID 2 from xml into table and delete product ID 3 from table since it’s not found in xml
Please any help is appreciated.
Since you already have the flowchart of the desired process, it should be pretty straightforward.
I am not doing any data sanitization / escaping, as you do it as per your requirements.
XML FILE: (save it as testFeed.xml)PHP Code:MySQL INSERT … ON DUPLICATE UPDATE example here.
Hope this helps.