1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/scripts/niceXML Wed Feb 27 16:09:06 2008 +0000
1.3 @@ -0,0 +1,64 @@
1.4 +#!/usr/bin/perl
1.5 +#
1.6 +# Hack to make single-line XML file easier to read by using indention
1.7 +#
1.8 +# (c) Uwe Drechsel
1.9 +#
1.10 +# License: GPL
1.11 +
1.12 +my $filename =shift;
1.13 +my $s;
1.14 +open (INFILE, "<$filename") ||
1.15 + die "Could not read $filename.";
1.16 +$s=join("\n",<INFILE>);
1.17 +
1.18 +$s=~s/>/>\n/gm;
1.19 +
1.20 +my @lines=split ("\n",$s);
1.21 +my $i=0;
1.22 +my $is="";
1.23 +
1.24 +foreach (@lines)
1.25 +{
1.26 + if (!/<.*?\/>/)
1.27 + {
1.28 + if (/<\//)
1.29 + {
1.30 + # Closing tag
1.31 + $i--;
1.32 + if ($i<0) {$i=0};
1.33 + $is=indent($i);
1.34 + print "$is$_\n";
1.35 + } else
1.36 + {
1.37 + if (/<(?!\?)/) # ignore <? ... ?>
1.38 + {
1.39 + # Opening tag
1.40 + print "$is$_\n";
1.41 + $i++;
1.42 + $is=indent($i);
1.43 + } else
1.44 + {
1.45 + # empty lines etc
1.46 + print "$is$_\n";
1.47 + }
1.48 + }
1.49 + } else
1.50 + {
1.51 + # Ignor single tags <../>
1.52 + print "$is$_\n";
1.53 + }
1.54 +}
1.55 +print "\n";
1.56 +exit;
1.57 +
1.58 +sub indent()
1.59 +{
1.60 + my $size=shift;
1.61 + my $s="";
1.62 + for ($i=0; $i<$size; $i++)
1.63 + {
1.64 + $s=$s." ";
1.65 + }
1.66 + return $s;
1.67 +}