lib/geo_ruby/kml.rb
def parse(kml)
      @factory.reset
      @with_z = false
      @parser = REXML::Parsers::PullParser.new(kml)
      while @parser.has_next?
        e = @parser.pull
        if e.start_element?
          if (type = ELEMENT_MAP[e[0]])
            @factory.begin_geometry(type)
          else
            @buffer = '' if (e[0] == 'coordinates') # clear the buffer
            accumulate_start(e)
          end
        elsif e.end_element?
          if ELEMENT_MAP[e[0]]
            @factory.end_geometry(@with_z)
            @buffer = '' # clear the buffer
          else
            accumulate_end(e)
            if (e[0] == 'coordinates')
              parse_coordinates(@buffer)
              @buffer = '' # clear the buffer
            end
          end
        elsif e.text?
          accumulate_text(e)
        elsif e.cdata?
          accumulate_cdata(e)
        end
      end
      @factory.geometry.dup
    end
def parse(kml)
      @factory.reset
      @with_z = false
      @parser = REXML::Parsers::PullParser.new(kml)
      while @parser.has_next?
        e = @parser.pull
        if e.start_element?
          if (type = ELEMENT_MAP[e[0]])
            @factory.begin_geometry(type)
          else
            @buffer = '' if (e[0] == 'coordinates') # clear the buffer
            accumulate_start(e)
          end
        elsif e.end_element?
          if ELEMENT_MAP[e[0]]
            @factory.end_geometry(@with_z)
            @buffer = '' # clear the buffer
          else
            accumulate_end(e)
            if (e[0] == 'coordinates')
              parse_coordinates(@buffer)
              @buffer = '' # clear the buffer
            end
          end
        elsif e.text?
          accumulate_text(e)
        elsif e.cdata?
          accumulate_cdata(e)
        end
      end
      @factory.geometry.dup
    end
argument should be a valid kml geometry fragment ie. <Point> .... </Point>
 returns the GeoRuby geometry object back