26575
|
1 |
#
|
|
2 |
# $Id$
|
|
3 |
# Author: Makarius
|
|
4 |
#
|
|
5 |
# yxml.pl - simple XML to YXML converter
|
|
6 |
#
|
|
7 |
|
|
8 |
use strict;
|
|
9 |
use XML::Parser;
|
|
10 |
|
|
11 |
binmode(STDOUT, ":utf8");
|
|
12 |
|
|
13 |
sub handle_start {
|
|
14 |
print chr(5), chr(6), $_[1];
|
|
15 |
for (my $i = 2; $i <= $#_; $i++) {
|
|
16 |
print ($i % 2 == 0 ? chr(6) : "=");
|
|
17 |
print $_[$i];
|
|
18 |
}
|
|
19 |
print chr(5);
|
|
20 |
}
|
|
21 |
|
|
22 |
sub handle_end {
|
|
23 |
print chr(5), chr(6), chr(5);
|
|
24 |
}
|
|
25 |
|
|
26 |
sub handle_char {
|
|
27 |
print $_[1];
|
|
28 |
}
|
|
29 |
|
|
30 |
my $parser = new XML::Parser(Handlers =>
|
|
31 |
{Start => \&handle_start,
|
|
32 |
End => \&handle_end,
|
|
33 |
Char => \&handle_char});
|
|
34 |
|
26593
|
35 |
$parser->parse(*STDIN) or die $!;
|
26575
|
36 |
|