I'm trying to generate KML using Builder. I know their are some options out there to help with this but I will be doing some 2.2 specific things that aren't supported by the KML gems I've looked at and would generally like to be able to accomplish this leveraging just an XML framework.
I get a tag at the end of the file when rendering my kml/xml. I strongly suspect I'm missing something basic with setting up my Builder object or with how I'm rendering the output it. Here's a simple example that demonstrates the issue:
def kml2dot2
@site = Site.find(params[:id])
xml = Builder::XmlMarkup.new(:indent => 2)
xml.instruct!
xml.kml("xmlns" => "http://www.opengis.net/kml/2.2") {
xml.Placemark do
xml.name @site.mapNameFull
xml.Point do
xml.coordinates @site.lat.to_s + "," + @site.lng.to_s + ",0"
end
end
}
render :text => xml, :type=>"text/kml"
end
Produces:
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Placemark>
<name>Seattle City Hall</name>
<Point>
<coordinates>47.6040746,-122.33005,0</coordinates>
</Point>
</Placemark>
</kml>
<to_s/>
I'm trying to understand how to avoid the <to_s/>
being included and what I'm doing wrong with Builder. Thanks for any insight.