Convertir archivos XML a CSV

¿Necesitas pasar de un archivo XML a un archivo CSV para hacerlo compatible con tu sistema de importación? A continuación te mostramos el código necesario para porder realizar esta tarea de convertir XML a CSV.

Ejemplo archivo XML:

<libros>
    <libro>
      <nombre>Tía Clara</nombre>
      <precio>13.50></precio>
   </libro>
</libros>

Código para el archivo PHP:

$filexml='archivo.xml';
  if (file_exists($filexml)) {
    $xml = simplexml_load_file($filexml);
    $f = fopen('nombre_archivo_csv.csv', 'w');
    foreach ($xml->libro as $item) {
      fputcsv($f, get_object_vars($item),',','"');
    }
fclose($f);
}
Compartir:
  • Twitter
  • Facebook
  • Print
  • RSS
  • Digg
  • del.icio.us
  • Technorati
  • Google Bookmarks
Esta entrada fue publicada en PHP y etiquetada . Guarda el enlace permanente.

22 respuestas a Convertir archivos XML a CSV

  1. Nona dijo:

    Wow, your post makes mine look feblee. More power to you!

  2. elvis dijo:

    Amazing post! I initially found your blog a week or so ago, and I want to subscribe to your RSS feed.

  3. javier dijo:

    Excellent post it is really. We’ve been awaiting for this info.

  4. Grace Foster dijo:

    la digitalizacion de documentos es el proceso de convertir sus archivos en papel de cualquier tipo, forma , tama

  5. I suggest adding a “google+” button for the blog!
    Hellen

  6. Los ejemplos de trabajo son bien inteligentes al igual que la exposición! Mantener este tipo de acciones es impresionante. La información leida es especial y por ello la eh adicionado a la lista de mis sitios importantes.

  7. Glenn Marois dijo:

    Awesome post! I will keep an on eye on your blog.

  8. Prices dijo:

    Glad to read this blog! Keep it going!

  9. pepetrueno dijo:

    I know this if off topic but I’m looking into starting my own blog and was wondering what all is needed to get set up? I’m assuming having a blog like yours would cost a pretty penny? I’m not very internet savvy so I’m not 100% positive. Any suggestions or advice would be greatly appreciated. Cheers

  10. Yo. Just simply needed to leave a short note and tell you that I’ve appreciated viewing your specific blog and am promoting it to my close friends. Keep up the good work! Thanks.

  11. Standard & Poor’s – one of the three top rating agencies – is expected to cut France’s rating within days, in a move that would weaken its ability to raise funds on financial markets.

  12. Azel dijo:

    Useful information and wonderful design you got here! I would like to thank you for sharing your ideas and putting the time into the articles you publish! Nice work!

  13. Brinda Reary dijo:

    I truly wanted to compose a simple comment in order to express gratitude to you for those fantastic points you are showing on this website. My time intensive internet research has now been honored with reasonable tips to share with my partners. I ‘d point out that most of us website visitors actually are truly blessed to live in a fine site with many special individuals with interesting tips. I feel extremely fortunate to have come across the weblog and look forward to some more fabulous moments reading here. Thank you again for everything.

  14. Gabril dijo:

    ome truly wonderful things on this online site , I take pleasure in it.

  15. Berline dijo:

    certainly, i truly concur with you, i like your submit, i assure someday i will be back to scan you page all over again, essentially value it, i will bookmark it

  16. Pawl dijo:

    Was initially investigating this certain stuff through the use of google when I stumbled with your web-site. A great amount fantastic information on here. Unquestionably a single for my favs. Lance

  17. AYYY BABY QUE PASO!

  18. I am grateful to you for this wonderful content. You actually did make my day :

  19. Excellent goods from you, man. Convertir archivos XML a CSV | Designer Studio I’ve understand your stuff previous to and you’re just extremely wonderful. I really like what you’ve acquired here, certainly like what you are saying and the way in which you say it. You make it entertaining and you still take care of to keep it wise. I can not wait to read much more from you. This is really a great Convertir archivos XML a CSV | Designer Studio informations.

  20. Magnificent goods from you, man. Convertir archivos XML a CSV | Designer Studio I’ve understand your stuff previous to and you’re just extremely great. I actually like what you’ve acquired here, certainly like what you are stating and the way in which you say it. You make it enjoyable and you still take care of to keep it smart. I cant wait to read much more from you. This is really a wonderful Convertir archivos XML a CSV | Designer Studio informations.

  21. Fantastic goods from you, man. Convertir archivos XML a CSV | Designer Studio I’ve understand your stuff previous to and you’re just too great. I really like what you have acquired here, certainly like what you are saying and the way in which you say it. You make it enjoyable and you still care for to keep it smart. I can not wait to read far more from you. This is really a great Convertir archivos XML a CSV | Designer Studio informations.