當前位置: 首頁>>代碼示例>>Python>>正文


Python sax.expatreader方法代碼示例

本文整理匯總了Python中xml.sax.expatreader方法的典型用法代碼示例。如果您正苦於以下問題:Python sax.expatreader方法的具體用法?Python sax.expatreader怎麽用?Python sax.expatreader使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在xml.sax的用法示例。


在下文中一共展示了sax.expatreader方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_filter_basic

# 需要導入模塊: from xml import sax [as 別名]
# 或者: from xml.sax import expatreader [as 別名]
def test_filter_basic(self):
        result = StringIO()
        gen = XMLGenerator(result)
        filter = XMLFilterBase()
        filter.setContentHandler(gen)

        filter.startDocument()
        filter.startElement("doc", {})
        filter.characters("content")
        filter.ignorableWhitespace(" ")
        filter.endElement("doc")
        filter.endDocument()

        self.assertEqual(result.getvalue(), start + "<doc>content </doc>")

# ===========================================================================
#
#   expatreader tests
#
# =========================================================================== 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:22,代碼來源:test_sax.py

示例2: test_make_parser

# 需要導入模塊: from xml import sax [as 別名]
# 或者: from xml.sax import expatreader [as 別名]
def test_make_parser(self):
        # Creating a parser should succeed - it should fall back
        # to the expatreader
        p = make_parser(['xml.parsers.no_such_parser']) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:6,代碼來源:test_sax.py

示例3: test_sf_1511497

# 需要導入模塊: from xml import sax [as 別名]
# 或者: from xml.sax import expatreader [as 別名]
def test_sf_1511497(self):
        # Bug report: http://www.python.org/sf/1511497
        import sys
        old_modules = sys.modules.copy()
        for modname in sys.modules.keys():
            if modname.startswith("xml."):
                del sys.modules[modname]
        try:
            import xml.sax.expatreader
            module = xml.sax.expatreader
            self.assertEqual(module.__name__, "xml.sax.expatreader")
        finally:
            sys.modules.update(old_modules) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:15,代碼來源:test_sax.py

示例4: test_make_parser

# 需要導入模塊: from xml import sax [as 別名]
# 或者: from xml.sax import expatreader [as 別名]
def test_make_parser(self):
        # Creating a parser should succeed - it should fall back
        # to the expatreader
        p = make_parser(['xml.parsers.no_such_parser'])


# ===== XMLGenerator 
開發者ID:dxwu,項目名稱:BinderFilter,代碼行數:9,代碼來源:test_sax.py


注:本文中的xml.sax.expatreader方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。