simplekml包提供了这个介绍示例:
import simplekml
kml = simplekml.Kml()
kml.newpoint(name="Kirstenbosch", coords=[(18.432314,-33.988862)]) # lon, lat, optional height
kml.save("botanicalgarden.kml")
我想将其扩展如下,以获得描述中的超链接:
import simplekml
kml = simplekml.Kml()
pnt = kml.newpoint(name="Kirstenbosch",
coords=[(18.432314,-33.988862)],
description='<a href="https://en.wikipedia.org/wiki/Kirstenbosch_National_Botanical_Garden">Please go here</a>')
kml.save("botanicalgarden.kml")
但是,当我查看生成的 KML 文件时,超链接已转换为文本:
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2">
<Document id="feat_7">
<Placemark id="feat_8">
<name>Kirstenbosch</name>
<description><a href="https://en.wikipedia.org/wiki/Kirstenbosch_National_Botanical_Garden">Please go here</a></description>
<Point id="geom_3">
<coordinates>18.432314,-33.988862,0.0</coordinates>
</Point>
</Placemark>
</Document>
</kml>
根据这个页面,我应该看起来更像这样(用 CDATA 包裹的超链接):
<description><![CDATA[
<A href="http://stlab.adobe.com/wiki/images/d/d3/Test.pdf">test link</A>]]></description>
我需要在 simplekml 中做什么才能正确获取 .KML 文件中的超链接?