本文整理汇总了Python中XML.getChildElements方法的典型用法代码示例。如果您正苦于以下问题:Python XML.getChildElements方法的具体用法?Python XML.getChildElements怎么用?Python XML.getChildElements使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XML
的用法示例。
在下文中一共展示了XML.getChildElements方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: dbIter
# 需要导入模块: import XML [as 别名]
# 或者: from XML import getChildElements [as 别名]
def dbIter(self):
if os.path.isfile(self.path):
dom = XML.parseStream(open(self.path))
for element in XML.getChildElements(dom.documentElement):
if element.nodeName == "ruleset":
yield element
else:
log.msg("The file %r does not exist, loading no rulesets" % self.path)
示例2: loadParametersFrom
# 需要导入模块: import XML [as 别名]
# 或者: from XML import getChildElements [as 别名]
def loadParametersFrom(self, xml, unused=None):
"""This is given a <formatter> element possibly containing
extra parameters for the formatter to process and store.
Any problems should be signalled with an XML.XMLValidityError.
By default, this tries to find a param_* handler for each
element it comes across.
Returns a set object, containing the names of all unused
parameters. This allows callers, during validation, to look
for misspelled or otherwise unused elements.
"""
unused = set()
for tag in XML.getChildElements(xml):
f = getattr(self, 'param_'+tag.nodeName, None)
if f:
f(tag)
else:
unused.add(tag.nodeName)
return unused
示例3: postprocessMessage
# 需要导入模块: import XML [as 别名]
# 或者: from XML import getChildElements [as 别名]
def postprocessMessage(self, xml):
"""Gets a chance to modify all XML messages before they're loaded
and dispatched to the Hub. This does the following:
- If there is no <generator> at all, adds a generic one
- Removes any <mailHeaders> tag that may already exist in <generator>
- Adds a correct <mailHeaders> tag to the <generator>
"""
# Create the <generator> tag if it doesn't exist
if not XML.dig(xml, "message", "generator"):
xml.documentElement.appendChild(self.getLocalGenerator(xml))
generator = XML.dig(xml, "message", "generator")
# Delete an existing <mailHeaders>
for child in list(XML.getChildElements(generator)):
if child.nodeName == "mailHeaders":
generator.removeChild(child)
# Add a new <mailHeaders>
generator.appendChild(self.getXMLMailHeaders(xml))
return xml
示例4: element_or
# 需要导入模块: import XML [as 别名]
# 或者: from XML import getChildElements [as 别名]
def element_or(self, element):
"""Evaluates to True if and only if any child function evaluates to True"""
return "(%s)" % (" OR ".join([self.parse(node) for node in XML.getChildElements(element)]))
示例5: element_and
# 需要导入模块: import XML [as 别名]
# 或者: from XML import getChildElements [as 别名]
def element_and(self, element):
"""Evaluates to True if and only if all child expressions evaluate to True"""
return "(%s)" % (" AND ".join([self.parse(node) for node in XML.getChildElements(element)]))