您的位置:首页 > 编程语言 > Python开发

Python_API_Structured Markup Processing Tools_sgmllib.SGMLParser

2012-04-07 15:59 267 查看
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.

class
sgmllib.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类是不带参数的实例。可通过编码接卸如下文档结构:

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

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

         实体引用。例如:html©

        注释:<!--->

    

   
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息