25 de febrero de 2010

making KML files con perl

Simple Placemark:

  Simple placemark
  Attached to the ground. Intelligently places itself
     at the height of the underlying terrain.
  
    -122.0822035425683,37.42228990140251,0
  
Descripción:

XML script from http://www.perlmonks.org/index.pl?node_id=31565
#!/bin/perl -w
 use strict;
 use XML::Writer;
 use IO;
 my $doc = new IO::File(">doc.xml");
 my $writer = new XML::Writer(OUTPUT => $doc);
 $writer->startTag("doc", class => "simple");           # tag + att
  $writer->dataElement( 'title', "Simple XML Document");# text elt
  $writer->startTag( "section");
   $writer->dataElement( 'title', "Introduction",      
                         no => 1, type => "intro");
   $writer->startTag( "para");
    $writer->characters( "a text with");
    $writer->dataElement( 'bold', "bold");
    $writer->characters( " words.");
   $writer->endTag( "para");
  $writer->endTag();                        # close section      
 $writer->endTag();                         # close doc
 $writer->end();                            # check that the doc
                                            # has only one element
 $doc->close(); # fixed (was $output->close(); ) as suggested by the p
+ost below

Ref.:
Tutorial de KML
Tutorial de KML para Google Earth

No hay comentarios:

Publicar un comentario