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


Python XML.textlist方法代码示例

本文整理汇总了Python中xml.etree.ElementTree.XML.textlist方法的典型用法代码示例。如果您正苦于以下问题:Python XML.textlist方法的具体用法?Python XML.textlist怎么用?Python XML.textlist使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在xml.etree.ElementTree.XML的用法示例。


在下文中一共展示了XML.textlist方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: XML

# 需要导入模块: from xml.etree.ElementTree import XML [as 别名]
# 或者: from xml.etree.ElementTree.XML import textlist [as 别名]
xhmtl_fragment = XML('''
<ul>
<li>XHTML documents start with an <span class="code">&lt;html&gt;</span> tag - there is no such thing as an <span class="code">&lt;xhtml&gt;</span> tag.</li>
<li>It is required that you declare the XHTML namespace inside the opening <span class="code">&lt;html&gt;</span> tag.</li>
<li>This XHTML example covered the use of XHTML transitional - for XHTML strict or frameset, use the appropriate
<a title="Declaring a DocType" href="/xhtml/doctype/" >DOCTYPE Declaration</a>.</li>
<li>Remember that declaring a DOCTYPE with a valid identifier at the top of an XHTML page puts most browers
in <i>standards</i> mode- so remember not to use old browser hacks, and non-standard tags. (Otherwise, use just use regular HTML)</li>
<li>For some browsers, including Microsoft Internet Explorer 6, if you start an XHTML page with the XML declaration,
the browser goes into <i>quirks</i> mode, an unfortunate bug. The workaround is to delete the optional 
declaration and declare the the encoding using a meta tag.</li>
<li>The DOCTYPE declaration has to be in all uppercase characters, just like in the XHTML example code.</li>
</ul>
''')

print fill(''.join(xhmtl_fragment.textlist()))


docbook_fragment = XML('''
<book id="ashortbook">
  <title>History of Computer Programming</title>
  <chapter id="afirstchapter">
    <title>Chapter 1 -- Evolution</title>
    <para>In the beginning, there was machine language.   Then, arose assember.</para>
    <para>From those humble beginnings, a thousand languages were born.</para>
  </chapter>
  <chapter id="asecondchapter">
    <title>Chapter 2 -- Consolidation </title>
    <para>Eventually, all designs converged on variants on LISP.</para>
  </chapter>
</book>
开发者ID:bhramoss,项目名称:code,代码行数:33,代码来源:recipe-498286.py


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