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


Python pulldom.PROCESSING_INSTRUCTION属性代码示例

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


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

示例1: testProcessingInstruction

# 需要导入模块: from xml.dom import pulldom [as 别名]
# 或者: from xml.dom.pulldom import PROCESSING_INSTRUCTION [as 别名]
def testProcessingInstruction(self):
        piText = []
        for event, node in pulldom.parse(self.testFile):
            if event == pulldom.PROCESSING_INSTRUCTION:
                piText.append(node.data)
        try:
            result = u"".join(piText)
            # Weird how the repr for PI data is different from text and char data.
            # Still, the whole xml.dom.* and xml.sax.* hierarchy is rather a 
            # labyrinthine mess under jython, mostly because it's so old, and
            # yet survived through major evolutionary changes in both jython and java.
            self.failUnlessEqual(repr(result), r"u'ΛΜΝΞΟ'")
        except Exception, x:
            self.fail("Unexpected exception joining pi data pieces: %s" % str(x)) 
开发者ID:ofermend,项目名称:medicare-demo,代码行数:16,代码来源:test_pulldom.py

示例2: _test_thorough

# 需要导入模块: from xml.dom import pulldom [as 别名]
# 或者: from xml.dom.pulldom import PROCESSING_INSTRUCTION [as 别名]
def _test_thorough(self, pd, before_root=True):
        """Test some of the hard-to-reach parts of the parser, using a mock
        parser."""

        evt, node = next(pd)
        self.assertEqual(pulldom.START_DOCUMENT, evt)
        # Just check the node is a Document:
        self.assertTrue(hasattr(node, "createElement"))

        if before_root:
            evt, node = next(pd)
            self.assertEqual(pulldom.COMMENT, evt)
            self.assertEqual("a comment", node.data)
            evt, node = next(pd)
            self.assertEqual(pulldom.PROCESSING_INSTRUCTION, evt)
            self.assertEqual("target", node.target)
            self.assertEqual("data", node.data)

        evt, node = next(pd)
        self.assertEqual(pulldom.START_ELEMENT, evt)
        self.assertEqual("html", node.tagName)

        evt, node = next(pd)
        self.assertEqual(pulldom.COMMENT, evt)
        self.assertEqual("a comment", node.data)
        evt, node = next(pd)
        self.assertEqual(pulldom.PROCESSING_INSTRUCTION, evt)
        self.assertEqual("target", node.target)
        self.assertEqual("data", node.data)

        evt, node = next(pd)
        self.assertEqual(pulldom.START_ELEMENT, evt)
        self.assertEqual("p", node.tagName)

        evt, node = next(pd)
        self.assertEqual(pulldom.CHARACTERS, evt)
        self.assertEqual("text", node.data)
        evt, node = next(pd)
        self.assertEqual(pulldom.END_ELEMENT, evt)
        self.assertEqual("p", node.tagName)
        evt, node = next(pd)
        self.assertEqual(pulldom.END_ELEMENT, evt)
        self.assertEqual("html", node.tagName)
        evt, node = next(pd)
        self.assertEqual(pulldom.END_DOCUMENT, evt) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:47,代码来源:test_pulldom.py


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