Python_API_Structured Markup Processing Tools_sgmllib.SGMLParser

来源:互联网 发布:美国网络战司令部 编辑:程序博客网 时间:2024/06/05 09:09

API文档:

    This module defines a class SGMLParser which serves as the basis for parsing text files formatted in SGML (Standard Generalized Mark-up Language). In fact, it does not provide a full SGML parser — it only parses SGML insofar as it is used by HTML, and the module only exists as a base for the htmllib module. Another HTML parser which supports XHTML and offers a somewhat different interface is available in the HTMLParser module.

classsgmllib.SGMLParser
     The SGMLParser class is instantiated without arguments. The parser is hardcoded to recognize the following constructs:              
  • Opening and closing tags of the form <tag attr="value" ...> and </tag>, respectively.
  • Numeric character references of the form &#name;.
  • Entity references of the form &name;.
  • SGML comments of the form <!--text-->. Note that spaces, tabs, and newlines are allowed between the trailing> and the immediately preceding--.




翻译文档:

      这个模块定义了一个SGMLParser类,这个类提供了解析SGML(标准通用标示语言)的功能。

但是他并没有提供完整的对SGML的解析功能。这个模块只是为htmllib模块定义了一个基本的方法。这个HTMLParser模块定义了以写可解析XHTML的方法和其他功能。

     这个SGMLParser类不带参数的实例通过编码接卸如下文档结构

         可分别标签开始和结束。例如 :<tagattr="value" ...> and </tag>,

         特殊字符引用。例如:&#name;.等,16进制字符转化等

         实体引用。例如:html&copy

        注释:<!--->


    

   


原创粉丝点击