[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[FWP] xml parser



<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;};
($£?(($^ eq '>')?($£,$@)=&$a($£,$@):$@.=$^):(($^ eq
'<')?($£,$@)=&$a($£,$@):$@.=$^))while(read(DATA,$^,1));
__END__
<root><parent><subparent>perl</subparent><its>foo</its><something/><subparent><what/>bar</subparent></parent></root>


_______________________________________________
Perl-XML mailing list
Perl-XML@listserv.ActiveState.com
http://listserv.ActiveState.com/mailman/listinfo/perl-xml



Andy Bach, Sys. Mangler     	    CC:Mail andy bach at ~7ca-chicago
Internet: andy@wiwb.uscourts.gov    VOICE: (608) 264-5178 ex 5738, FAX 264-510

'In order to know soup, it is not necessary to climb into a pot and be boiled.' 
 		Oliver Heaviside, English physicist, 



==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe