- The code (left out the CDATA section)
foreach my $id (keys %{$data}) {
my $placemark = $dom->createElement('Placemark');
my $name = $dom->createElement('name');
$name->appendTextNode( $data->{$id}->{name} );
my $style_url = $dom->createElement('styleUrl');
$style_url->appendTextNode( '#' . lc($data->{$id}->{num}) .
'Style' );
my $description = $dom->createElement('description');
my $point = $dom->createElement('Point');
my $coordinates = $dom->createElement('coordinates');
$coordinates->appendTextNode( $data->{$id}->{longitude} . ','
. $data->{$id}->{latitude} );
$point->appendChild($coordinates);
$placemark->appendChild($style_url);
$placemark->appendChild($name);
$placemark->appendChild($description);
$placemark->appendChild($point);
$document->appendChild($placemark);
}