
Jane
Novice
Jul 14, 2003, 6:10 AM
Post #2 of 4
(338 views)
|
|
Re: [Saya] XML attributes and values
[In reply to]
|
Can't Post
|
|
my $str = qq(<data><tuple name="Abb">ARG</tuple><tuple name="Reg">EU</tuple></data> <data><tuple name="Abb">ARG</tuple><tuple name="Reg">a_neh_2-vf-4nm</tuple></data> <data><tuple name="Abb">ARG</tuple><tuple name="Reg">a_neh_2-vf-4nm</tuple></data> <data><tuple name="Abb">ARG</tuple><tuple name="Reg">HGYIuy 6798</tuple></data>); # There's probably a better way but you can try these. # Providing your values don't contain '<', # to create an array you could... my @vals; $str =~ s/name="Reg">([^<]*)</push@vals,$1/eg; print "$_\n" for @vals; # Or to create a hash you could... my %h; my $name = 1; $str =~ s/name="Reg">([^<]*)</$h{$name++}=$1/eg; print "$h{$_}\n" foreach keys %h; Jane. Think |negatively :(| map{$,--%(5>>1)^0?push@y,$_:unshift@y,$_}sort(Hacker=>another=>Perl=>Just);for(1&1=>1|0){push@y,shift@y}print"@y";
|