Utilisateur:Kipmaster/xml extract ns0.pl
#!/usr/bin/perl $intext = 0 ; $titlebien = 0 ; while (<>) { if ( $_ =~ /<title>(.*?)<\/title>/ ) { if ( $1 =~ /:/ ) { # pas interessant, le titre n'est pas de namespace 0 $titlebien = 0 ; } else { $titlebien = 1 ; print "\n$_" ; } } if ( $titlebien == 1 ) { $ligne = $_ ; if ( $_ =~ /<text.*?>(.*)/) { $intext = 1 ; $ligne = $1 ; } if ( $_ =~ /(.*)<\/text>/) { print $1 ; $intext = 0 ; } elsif ( $intext == 1 ) { print $ligne ; } } # if ( $titlebien == 1 ) }