oh yes thanks for that! thanks. i overlooked that. my big... anyways, here's the correct xml version:
<? xml version="1.0" standalone="yes" ?> <albums> <owner>Percy</owner> <category name ="rock"> <artist>Alice in Chains</artist> <artist>The Pixies</artist> <artist>Percy and the Test Tube Babies</artist> </category> <category name = "reggae"> <artist>Bob Marley</artist> <artist>Peter Tosh</artist> <artist>Percy Gone Jazz</artist> </category> </albums> in using xml parser, how can i get the content of element 'owner'? i created the code but every content between the xml elements we parsed. here's my code: #! /usr/local/bin/perl use XML::Parser; my $parser = new XML::Parser (); $parser->setHandlers (Start => \&Start_handler, End => \&End_handler, Default => \&Default_handler ); my $filename = shift; die "Can't find '$filename': $!\n" unless -f $filename; $parser->parsefile ($filename); sub Start_handler { my $p = shift; my $el = shift; if ($el =~ m/owner/g) {print "<$el>"}; } sub End_handler { my ($p,$el) = @_; if ($el =~ m/owner/g) { print "</$el>\n"; }; } sub Default_handler { my ($p,$str) = @_; # my $p = shift; # my $str = shift; if (($str =~m/Percy/g) or ($str =~m/Percy/g)){ print "\n$str\n"; } } On Fri, 1 Feb 2002 10:27:37 -0500 "Hanson, Robert" <[EMAIL PROTECTED]> wrote: |By the way, there were a lot of XML errors in that example. | |<categories="rock"> | |You need an attribute name, this is not legal. | |<artist>Alice in Chains</rock> | |The closing tag does not match the opening tag. | |<categories = "reggae"> | |You need an attribute name, this is not legal. | |Rob | | |-----Original Message----- |From: P0R0NG [mailto:[EMAIL PROTECTED]] |Sent: Friday, February 01, 2002 8:05 AM |To: [EMAIL PROTECTED] |Subject: PERL and XML Parser | | |Hi list. | |I'm currently doing a perl project involving XML parser. | |given this xml snippet: | |<albums> | <owner>Percy</owner> | <categories="rock"> | <artist>Alice in Chains</rock> | <artist>The Pixies</artist> | </categories> | <categories = "reggae"> | <artist>Bob Marley</artist> | <artist>Peter Tosh</artist> | </categories> |</albums> _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]