From: Kragen Sitaker (kragen@pobox.com)
Date: Fri Aug 18 2000 - 11:05:35 PDT
Note that this has been corrupted via cut-and-paste and, apparently,
prior decoding.
<sigh>
Some day I hope to be clever enough but till then:
Somebody else's 7 line xml (sort of) parser: The '$/043'
(that was a 'backslash043' below, but reversed here so emailers won't
change it to the russian 'yo' (?) or English pound symbol) is $^A or
$ACCUMULATOR var, I'm told.
---------- Forwarded message ----------
Date: Tue, 15 Aug 2000 18:02:55 +0100
From: David Ashe <dave@inta.net.uk>
A
...but somebody had to do it sooner or later...
xml parser including xml in 7 lines
does not support dtd's or entites, thats for the next version!
#!/usr/bin/perl
use strict; # xml path parser (c) david ashe
my $b=sub{print join('/',@{$_[0]}),'='.$_[1],"\n";};
my $a=sub{($_=$_[1])ne''?((s/^\///go)?pop
@@:((s/\/$//go)?&$b([@@,$_]):(($_[0])?push
@@,$_:&$b(\@@,$@))))&int(!$_[0]):return 1;};
($<A3>?(($^ eq '>')?($<A3>,$@)=&$a($<A3>,$@):$@.=$^):(($^ eq
'<')?($<A3>,$@)=&$a($<A3>,$@):$@.=$^))while(read(DATA,$^,1));
__END__
<root><parent><subparent>perl</subparent><its>foo</its><something/><subparent><w
hat/>bar</subparent></parent></root>
_______________________________________________
Perl-XML mailing list
Perl-XML@listserv.ActiveState.com
http://listserv.ActiveState.com/mailman/listinfo/perl-xml
This archive was generated by hypermail 2b29 : Fri Aug 18 2000 - 11:08:01 PDT