in reply to Re: OT: conversion of xml to csv before insert data into a database
in thread OT: conversion of xml to csv before insert data into a database

This node falls below the community's minimum standard of quality and will not be displayed.

Replies are listed 'Best First'.
Re^3: OT: conversion of xml to csv before insert data into a database
by Mr. Muskrat (Canon) on Mar 02, 2016 at 18:00 UTC

    That is XML and PHP.

    Do you have a Perl question? If so, ask it and provide the appropriate Perl code.

Re^3: OT: conversion of xml to csv before insert data into a database
by poj (Abbot) on Mar 03, 2016 at 13:21 UTC

    What you have is a php script, this is a perl script

    #!/usr/bin/perl use strict; use warnings; use XML::Twig; open my $fh,'>','sortie.csv' or die "$!"; my $t = XML::Twig->new( twig_handlers => { '/xml/element' => sub { my $nom = $_[1]->first_child('nom'); my $prenom = $_[1]->first_child('prenom'); $nom = (defined $nom) ? $nom->text : ''; $prenom = (defined $prenom) ? $prenom->text : ''; print $fh "$nom;$prenom\n"; } }, ); $t->parsefile('entree.xml'); close $fh;
    poj