本文整理汇总了Python中pykml.factory.KML_ElementMaker.linkDescription方法的典型用法代码示例。如果您正苦于以下问题:Python KML_ElementMaker.linkDescription方法的具体用法?Python KML_ElementMaker.linkDescription怎么用?Python KML_ElementMaker.linkDescription使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pykml.factory.KML_ElementMaker
的用法示例。
在下文中一共展示了KML_ElementMaker.linkDescription方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_getXmlWithCDATA
# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import linkDescription [as 别名]
def test_getXmlWithCDATA(self):
'''tests the format_as_cdata function'''
from pykml.util import format_xml_with_cdata
kmlobj = KML.kml(
KML.Document(
KML.Placemark(
KML.name('foobar'),
KML.styleUrl('#big_label'),
KML.description('<html>'),
KML.text('<html>'),
KML.linkDescription('<html>'),
KML.displayName('<html>')
)
)
)
self.assertEqual(
etree.tostring(format_xml_with_cdata(kmlobj)),
'<kml xmlns:gx="http://www.google.com/kml/ext/2.2"'
' xmlns:atom="http://www.w3.org/2005/Atom"'
' xmlns="http://www.opengis.net/kml/2.2">'
'<Document>'
'<Placemark>'
'<name>foobar</name>'
'<styleUrl>#big_label</styleUrl>'
'<description><![CDATA[<html>]]></description>'
'<text><![CDATA[<html>]]></text>'
'<linkDescription><![CDATA[<html>]]></linkDescription>'
'<displayName><![CDATA[<html>]]></displayName>'
'</Placemark>'
'</Document>'
'</kml>'
)
示例2: test_getXmlWithCDATA
# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import linkDescription [as 别名]
def test_getXmlWithCDATA(self):
"""tests the format_as_cdata function"""
from pykml.util import format_xml_with_cdata
kml_obj = KML.kml(
KML.Document(
KML.Placemark(
KML.name('foobar'),
KML.styleUrl('#big_label'),
KML.description('<html>'),
KML.text('<html>'),
KML.linkDescription('<html>'),
KML.displayName('<html>')
)
)
)
root = format_xml_with_cdata(kml_obj)
data = etree.tostring(root, encoding='utf-8', xml_declaration=True)
expected = \
'<?xml version="1.0" encoding="UTF-8"?>' \
'<kml xmlns:gx="http://www.google.com/kml/ext/2.2" ' \
'xmlns:atom="http://www.w3.org/2005/Atom" ' \
'xmlns="http://www.opengis.net/kml/2.2">' \
'<Document>' \
'<Placemark>' \
'<name>foobar</name>' \
'<styleUrl>#big_label</styleUrl>' \
'<description><![CDATA[<html>]]></description>' \
'<text><![CDATA[<html>]]></text>' \
'<linkDescription><![CDATA[<html>]]></linkDescription>' \
'<displayName><![CDATA[<html>]]></displayName>' \
'</Placemark>' \
'</Document>' \
'</kml>'
expected = expected.encode('utf-8')
self.assertXmlEquivalentOutputs(data, expected)