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


Python xml.sax方法代码示例

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


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

示例1: __init__

# 需要导入模块: import xml [as 别名]
# 或者: from xml import sax [as 别名]
def __init__(self, rules = None):
        xml.sax.handler.ContentHandler.__init__(self)
        self.body       = None
        self.header     = None
        self.attrs      = {}
        self._data      = None
        self._next      = "E" # Keeping state for message validity
        self._stack     = [self.Frame('SOAP')]

        # Make two dictionaries to store the prefix <-> URI mappings, and
        # initialize them with the default
        self._prem      = {NS.XML_T: NS.XML}
        self._prem_r    = {NS.XML: NS.XML_T}
        self._ids       = {}
        self._refs      = {}
        self._rules    = rules 
开发者ID:donSchoe,项目名称:p2pool-n,代码行数:18,代码来源:Parser.py

示例2: _parseSOAP

# 需要导入模块: import xml [as 别名]
# 或者: from xml import sax [as 别名]
def _parseSOAP(xml_str, rules = None):
    try:
        from cStringIO import StringIO
    except ImportError:
        from StringIO import StringIO

    parser = xml.sax.make_parser()
    t = SOAPParser(rules = rules)
    parser.setContentHandler(t)
    e = xml.sax.handler.ErrorHandler()
    parser.setErrorHandler(e)

    inpsrc = xml.sax.xmlreader.InputSource()
    inpsrc.setByteStream(StringIO(xml_str))

    # turn on namespace mangeling
    parser.setFeature(xml.sax.handler.feature_namespaces,1)

    parser.setFeature(xml.sax.handler.feature_external_ges, 0)

    try:
        parser.parse(inpsrc)
    except xml.sax.SAXParseException, e:
        parser._parser = None
        raise e 
开发者ID:donSchoe,项目名称:p2pool-n,代码行数:27,代码来源:Parser.py

示例3: reset

# 需要导入模块: import xml [as 别名]
# 或者: from xml import sax [as 别名]
def reset(self):
        self.pulldom = pulldom.SAX2DOM()
        # This content handler relies on namespace support
        self.parser.setFeature(xml.sax.handler.feature_namespaces, 1)
        self.parser.setContentHandler(self.pulldom) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:7,代码来源:test_pulldom.py

示例4: test_basic

# 需要导入模块: import xml [as 别名]
# 或者: from xml import sax [as 别名]
def test_basic(self):
        """Ensure SAX2DOM can parse from a stream."""
        with io.StringIO(SMALL_SAMPLE) as fin:
            sd = SAX2DOMTestHelper(fin, xml.sax.make_parser(),
                                   len(SMALL_SAMPLE))
            for evt, node in sd:
                if evt == pulldom.START_ELEMENT and node.tagName == "html":
                    break
            # Because the buffer is the same length as the XML, all the
            # nodes should have been parsed and added:
            self.assertGreater(len(node.childNodes), 0) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:13,代码来源:test_pulldom.py

示例5: __init__

# 需要导入模块: import xml [as 别名]
# 或者: from xml import sax [as 别名]
def __init__(self):
        xml.sax.ContentHandler.__init__(self) 
开发者ID:kermitt2,项目名称:delft,代码行数:4,代码来源:reader.py

示例6: test_saxutils_import_usage

# 需要导入模块: import xml [as 别名]
# 或者: from xml import sax [as 别名]
def test_saxutils_import_usage(self):
        python_node = self.get_ast_node(
            """
            import xml.sax.saxutils
            from xml.sax import saxutils
            """
        )

        linter = dlint.linters.BadXMLUseLinter()
        linter.visit(python_node)

        result = linter.get_results()
        expected = []

        assert result == expected 
开发者ID:duo-labs,项目名称:dlint,代码行数:17,代码来源:test_bad_xml_use.py

示例7: __init__

# 需要导入模块: import xml [as 别名]
# 或者: from xml import sax [as 别名]
def __init__(self):
        xml.sax.ContentHandler.__init__(self)
        self.root = None
        self.elements = []
        self.element = [] 
开发者ID:pywbem,项目名称:pywbem,代码行数:7,代码来源:_tupletree.py


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