in reply to Re: MS XAct XAP Data file parsing
in thread MS XAct XAP Data file parsing
Here is a naive parse function that receives reference to trimmed file lines.
sub ParseXAP { my $lines = shift; my @props = (); my @children = (); while( scalar( @{$lines} ) ) { my $line = shift @{$lines}; if( length($line) ) { last if $line eq '}'; if( $line =~ /(.*) = (.*);/ ) { push @props, { 'name' => $1, 'value' => $2 }; } else { my $type = $line; $line = shift @{$lines}; die unless $line eq '{'; my $child = ParseXAP( $lines ); $child->{type} = $type; push @children, $child; } } } return { 'props' => \@props, 'children' => \@children }; }
|
|---|