First page Back Continue Last page Overview Graphics
Example 3: code (cont.)
-
sub plant
{ my( $twig, $plant)= @_;
-
my $id= $plant->att( 'id');
my $update= $updates->elt_id( $id); # updates is global
-
if( $update)
{ foreach my $updated ( $update->children)
{ my $field = $updated->tag;
my $original = $plant->first_child( $field);
$original->replace_with( $updated);
-
warn "updating $id - $field: ", $original->text,
" => ", $updated->text, "\n";
}
}
$twig->flush; # prints the XML so far, and frees the memory
}