当前位置: 首页>>代码示例>>Python>>正文


Python KML_ElementMaker.linkDescription方法代码示例

本文整理汇总了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>'
     )
开发者ID:123abcde,项目名称:pykml,代码行数:35,代码来源:test_util.py

示例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)
开发者ID:recombinant,项目名称:pykml,代码行数:41,代码来源:test_util.py


注:本文中的pykml.factory.KML_ElementMaker.linkDescription方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。