aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorRob Austein <sra@hactrn.net>2007-06-20 15:17:13 +0000
committerRob Austein <sra@hactrn.net>2007-06-20 15:17:13 +0000
commit989d3d56412794f2a44bd46d72f8d7bcca6d8ed2 (patch)
treed56a910ca70501bbf8adb9442f058998468e6e28 /scripts
parent4c9b943f34f6bbe7ec1005265e121c4b93ab1299 (diff)
XML::Simple reverse translator for days when XML is easier to read
than Perl. svn path=/scripts/xml-simple-dump.pl; revision=675
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/xml-simple-dump.pl25
1 files changed, 25 insertions, 0 deletions
diff --git a/scripts/xml-simple-dump.pl b/scripts/xml-simple-dump.pl
new file mode 100755
index 00000000..909517c9
--- /dev/null
+++ b/scripts/xml-simple-dump.pl
@@ -0,0 +1,25 @@
+# $Id$
+#
+# XML::Simple is relatively easy to use (have you looked at the
+# alternatives?) but sometimes even XML::Simple's internal
+# representation is not immediately obvious. On days when it'd be
+# easier to write the XML by hand and let a machine tell you how
+# XML::Simple would represent it, run this script.
+
+eval 'exec perl -w -S $0 ${1+"$@"}'
+ if 0;
+
+use strict;
+use XML::Simple;
+use Data::Dumper;
+
+my $xs = XML::Simple->new(KeepRoot => 1,
+ ForceArray => [qw(list_class)],
+ KeyAttr => [qw(header)],
+ NormalizeSpace => 2);
+
+my @xml = <>;
+shift(@xml) while (@xml && $xml[0] =~ /^\s*$/);
+$xml[0] =~ s/^\s+// if (@xml);
+
+print(Dumper($xs->XMLin(join('', @xml))));