本文整理汇总了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))
示例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)