當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。