本文整理匯總了Python中xml.dom.Node.PROCESSING_INSTRUCTION_NODE屬性的典型用法代碼示例。如果您正苦於以下問題:Python Node.PROCESSING_INSTRUCTION_NODE屬性的具體用法?Python Node.PROCESSING_INSTRUCTION_NODE怎麽用?Python Node.PROCESSING_INSTRUCTION_NODE使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類xml.dom.Node
的用法示例。
在下文中一共展示了Node.PROCESSING_INSTRUCTION_NODE屬性的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _do_document
# 需要導入模塊: from xml.dom import Node [as 別名]
# 或者: from xml.dom.Node import PROCESSING_INSTRUCTION_NODE [as 別名]
def _do_document(self, node):
'''_do_document(self, node) -> None
Process a document node. documentOrder holds whether the document
element has been encountered such that PIs/comments can be written
as specified.'''
self.documentOrder = _LesserElement
for child in node.childNodes:
if child.nodeType == Node.ELEMENT_NODE:
self.documentOrder = _Element # At document element
self._do_element(child)
self.documentOrder = _GreaterElement # After document element
elif child.nodeType == Node.PROCESSING_INSTRUCTION_NODE:
self._do_pi(child)
elif child.nodeType == Node.COMMENT_NODE:
self._do_comment(child)
elif child.nodeType == Node.DOCUMENT_TYPE_NODE:
pass
else:
raise TypeError, str(child)
示例2: visit
# 需要導入模塊: from xml.dom import Node [as 別名]
# 或者: from xml.dom.Node import PROCESSING_INSTRUCTION_NODE [as 別名]
def visit(self, node):
if self._html is None:
# Set HTMLDocument flag here for speed
self._html = hasattr(node.ownerDocument, 'getElementsByName')
if node.nodeType == Node.ELEMENT_NODE:
return self.visitElement(node)
elif node.nodeType == Node.ATTRIBUTE_NODE:
return self.visitAttr(node)
elif node.nodeType == Node.TEXT_NODE:
return self.visitText(node)
elif node.nodeType == Node.CDATA_SECTION_NODE:
return self.visitCDATASection(node)
elif node.nodeType == Node.ENTITY_REFERENCE_NODE:
return self.visitEntityReference(node)
elif node.nodeType == Node.ENTITY_NODE:
return self.visitEntity(node)
elif node.nodeType == Node.PROCESSING_INSTRUCTION_NODE:
return self.visitProcessingInstruction(node)
elif node.nodeType == Node.COMMENT_NODE:
return self.visitComment(node)
elif node.nodeType == Node.DOCUMENT_NODE:
return self.visitDocument(node)
elif node.nodeType == Node.DOCUMENT_TYPE_NODE:
return self.visitDocumentType(node)
elif node.nodeType == Node.DOCUMENT_FRAGMENT_NODE:
return self.visitDocumentFragment(node)
elif node.nodeType == Node.NOTATION_NODE:
return self.visitNotation(node)
# It has a node type, but we don't know how to handle it
raise Exception("Unknown node type: %s" % repr(node))