Any interest in Perl and XML

taa0 at taa0 at
Sat May 20 00:23:03 CDT 2000

Bob La Quey wrote:

> How about showing us some exmple code. I did this stuff about a year ago
> as a learning exercise. I don't recall if XML::Simple was available then.
> Is is a SAX interface?

Not a SAX interface. Here's an example:

-------------- next part --------------
#!/usr/local/bin/perl -w

use XML::Simple;

my $in;

while(<DATA>) { $in .= $_; }

my $config = XMLin($in);

my $category = ${$config}{'category'};

print "category is $category\n";

my $fruithash = ${$config}{'fruit'};

foreach my $key (keys %$fruithash) {
	print "\t$key:\n";
	my $pair = ${$fruithash}{$key};
	foreach my $attrib (keys %$pair) {
		print "\t\t$attrib is ${$pair}{$attrib}\n";
	this is just a comment
<!DOCTYPE fruits [
<!ELEMENT fruits (category,fruit*)>
<!ELEMENT category (#PCDATA)>
<!ELEMENT fruit (name,color)>
<!ELEMENT color (#PCDATA)>

More information about the San-Diego-pm mailing list