set all [atomselect top "all"]
set n [llength [lsort -unique -integer [$all get fragment]]]
for { set i 0 } { $i < $n } { incr i } {
set sel [atomselect top "fragment $i"]
$sel writexyz mol_$i.xyz
}
my $doc=$Documents{"test.xsd"};
my $atoms=$doc->UnitCell->Atoms;
my $atom=undef;
foreach my $atom(@$atoms){
printf "%s %f %f %f\n", $atom->ElementSymbol, $atom->X, $atom->Y, $atom->Z;
}