#!/usr/bin/perl -w # Using XML::DT # Author: Jose Joao Dias de Almeida # modified by Michel Rodriguez use strict; use XML::DT ; my $i=0; my %handler=( -type => { prod => MMAPON("rhs","com","wfc","vc") }, -default => sub{"$c"}, com => sub{""}, #remove comments prod => sub{ $i++; my $prod= "[$i] $c->{lhs} ::= ". join("" , @{$c->{rhs}}); print clean( $prod), "\n"; } ); dt('/article/ways_to_rome/ex_ps_dt/REC_xml_19980210.xml',%handler); sub clean { my( $string)= @_; $string =~ s/\xc2\xa0/ /sg; $string =~ s/\s+/ /g; $string=~ s{\s$}{}g; return $string; }