本文整理汇总了Python中XML.addElement方法的典型用法代码示例。如果您正苦于以下问题:Python XML.addElement方法的具体用法?Python XML.addElement怎么用?Python XML.addElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XML
的用法示例。
在下文中一共展示了XML.addElement方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: preprocess
# 需要导入模块: import XML [as 别名]
# 或者: from XML import addElement [as 别名]
def preprocess(self):
message = XML.dig(self.xml, "message")
if not message:
raise XML.XMLValidityError("A Message's root node must be named 'message'")
# Stamp it with the current time if it has no timestamp yet
if not XML.dig(message, "timestamp"):
XML.addElement(message, "timestamp", "%d" % time.time())
示例2: getXMLMailHeaders
# 需要导入模块: import XML [as 别名]
# 或者: from XML import addElement [as 别名]
def getXMLMailHeaders(self, document):
"""Return a <mailHeaders> tag representing a subset of the headers
for this message. This is placed in the <generator> tag of any
message passing through this module, to document and log the
message's true source.
"""
node = document.createElementNS(None, "mailHeaders")
for name, value in self.message.items():
if name in interestingHeaders:
XML.addElement(node, "header", content=str(value)).setAttributeNS(None, 'name', name)
return node
示例3: getLocalGenerator
# 需要导入模块: import XML [as 别名]
# 或者: from XML import addElement [as 别名]
def getLocalGenerator(self, document):
"""Return a <generator> tag for messages produced locally"""
node = document.createElementNS(None, "generator")
XML.addElement(node, "name", content="CIA IncomingMailParser")
return node