lib/scripts/yxml.pl
author wenzelm
Sat Dec 20 11:55:34 2008 +0100 (2008-12-20)
changeset 29145 b1c6f4563df7
parent 26593 8375332b3c96
permissions -rw-r--r--
removed Ids;
     1 #
     2 # Author: Makarius
     3 #
     4 # yxml.pl - simple XML to YXML converter
     5 #
     6 
     7 use strict;
     8 use XML::Parser;
     9 
    10 binmode(STDOUT, ":utf8");
    11 
    12 sub handle_start {
    13   print chr(5), chr(6), $_[1];
    14   for (my $i = 2; $i <= $#_; $i++) {
    15     print ($i % 2 == 0 ? chr(6) : "=");
    16     print $_[$i];
    17   }
    18   print chr(5);
    19 }
    20 
    21 sub handle_end {
    22   print chr(5), chr(6), chr(5);
    23 }
    24 
    25 sub handle_char {
    26   print $_[1];
    27 }
    28 
    29 my $parser = new XML::Parser(Handlers =>
    30   {Start => \&handle_start,
    31     End => \&handle_end,
    32     Char => \&handle_char});
    33 
    34 $parser->parse(*STDIN) or die $!;
    35