saywhatyousee Posted December 7, 2013 Share Posted December 7, 2013 I have a csv file which contains this data: person1,person2,person3 first,john,steve,mike last,doe,whinney,speirs I want to create an xml file which looks like this: <root> <person1> <first> john </first> <last> doe </last> </person1> <person2> <first> steve </first> <last> whinney </last> </person2> <person3> <first> mike </first> <last> speirs </last> </person3> </root> Thanks Quote Link to comment https://forums.phpfreaks.com/topic/284595-how-do-i-convert-a-csv-file-to-xml-in-php/ Share on other sites More sharing options...
mac_gyver Posted December 7, 2013 Share Posted December 7, 2013 what have you tried? can you even read the csv file and access the data for each row? have you tried to even create the output file? exactly where are you stuck at in doing this? Quote Link to comment https://forums.phpfreaks.com/topic/284595-how-do-i-convert-a-csv-file-to-xml-in-php/#findComment-1461542 Share on other sites More sharing options...
Irate Posted December 7, 2013 Share Posted December 7, 2013 If you have created the output file, I suggest you use fopen, fgetcsv, feof and fputs or fwrite. Quote Link to comment https://forums.phpfreaks.com/topic/284595-how-do-i-convert-a-csv-file-to-xml-in-php/#findComment-1461543 Share on other sites More sharing options...
Barand Posted December 7, 2013 Share Posted December 7, 2013 I'd also recommend a better structure for your XML <root> <person seq="1"> <first> john </first> <last> doe </last> </person> etc </root> Quote Link to comment https://forums.phpfreaks.com/topic/284595-how-do-i-convert-a-csv-file-to-xml-in-php/#findComment-1461559 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.