help: php code that can generate an xml file from a csv file

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
gothica
Forum Newbie
Posts: 15
Joined: Thu Sep 08, 2005 5:24 am

help: php code that can generate an xml file from a csv file

Post by gothica »

im not sure if this is the right section for my question, however here goes..

i haven't started any coding just yet however is there anyone here who have made a code that can generate an xml file from a csv file? can you share the code with so i can study it? i have ideas on how to approach this problem but i just though i'd take my chances that someone out there might have already done it. i'll appreciate any help on this matter. thanks in advance! :D
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

can be as simple as

Code: Select all

...
$elementnames = array('one', 'two', 'three', 'four');
...
  $record = $dom->createElement('row');
  foreach($row as $key=>$val) {
    $element = $dom->createElement($elementnames[$key], $val);
    $record->appendChild($element);  
  }
  $dom->documentElement->appendChild($record);
...
depends on exactly what you're trying to achieve.
gothica
Forum Newbie
Posts: 15
Joined: Thu Sep 08, 2005 5:24 am

Post by gothica »

thanks for the tip. i'm already looking into it. i haven't coded in php for a long time now so i have to review a bit. :wink:
Post Reply