On Mon, 2009-01-05 at 08:17 -0800, Paul M wrote:
> If it were true XML,  I would say all children's Node Names. 
> so:
> <elema> <elemb> <elemc>
> 

You mean all the descendants.  The children of elem1 are elema and
elemb.  The descendants of elem1 are elema, elemb, and elemc.

#!/usr/bin/perl

use strict;
use warnings;

my $line = "<elem1><elema></elema><elemb><elemc></elemc></elemb></elem1>";

my @insides = $line =~ m{ \<elem1\> (.*?) \<\/elem1\> }gmsx;
for my $inside ( @insides ){
  while( $inside =~ m{ \G \<([^>]*)\> }gmsx ){
    my $element = $1;
    unless( $element =~ m{ \A \/ }msx ){
      print "$1\n";
    }
  }
}



-- 
Just my 0.00000002 million dollars worth,
  Shawn

Programming is as much about organization and communication as it is about 
coding.


-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to