本文整理汇总了Python中XML.parseString方法的典型用法代码示例。如果您正苦于以下问题:Python XML.parseString方法的具体用法?Python XML.parseString怎么用?Python XML.parseString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XML
的用法示例。
在下文中一共展示了XML.parseString方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: caps_store
# 需要导入模块: import XML [as 别名]
# 或者: from XML import parseString [as 别名]
def caps_store(self, path, xml):
"""Generate a list of acceptable capabilities to grant access to 'store'.
In addition to the usual ones, allow ('ruleset.uri', x) where x is the
ruleset's URI.
"""
if (xml.startswith('[')):
uri = xml.split('\n')[0][2:]
else:
uri = XML.parseString(xml).documentElement.getAttributeNS(None, 'uri')
return self.makeDefaultCaps(path) + [('ruleset.uri', uri)]
示例2: format
# 需要导入模块: import XML [as 别名]
# 或者: from XML import parseString [as 别名]
def format(self, args):
"""The formatter entry point. This just finds the current component
tree and invokes walkComponents and joinComponents on it.
"""
# Parse the default component tree, caching it per-class
if self.__class__._defaultTreeOwner is not self.__class__.defaultComponentTree:
self.__class__._defaultTreeOwner = self.__class__.defaultComponentTree
self.__class__._cachedDefaultTree = XML.parseString(self.__class__.defaultComponentTree).documentElement
# This will use the default component tree if it hasn't been overridden in this instance
tree = self.componentTree or self.__class__._cachedDefaultTree
return self.joinComponents(self.walkComponents(tree.childNodes, args))
示例3: dbStore
# 需要导入模块: import XML [as 别名]
# 或者: from XML import parseString [as 别名]
def dbStore(self, ruleset=None):
"""Write all rulesets to disk in one big XML file"""
doc = XML.parseString("<rulesets>\n"
"<!--\n"
"This is a ruleset storage for CIA. It tells the CIA server\n"
"how to deliver messages. Don't edit it by hand while the server\n"
"is running, use tools/ruleset_editor.py\n"
"-->\n"
"\n"
"</rulesets>")
root = doc.documentElement
for ruleset in self.flatten():
root.appendChild(XML.Domlette.ConvertDocument(ruleset.xml).documentElement)
root.appendChild(doc.createTextNode("\n\n"))
f = open(self.path, "w")
XML.Domlette.Print(doc, f)
f.write("\n")
示例4: command_DeliverXML
# 需要导入模块: import XML [as 别名]
# 或者: from XML import parseString [as 别名]
def command_DeliverXML(self):
"""Deliver a message already formatted in XML"""
# Note that parseString will convert UTF8 to Unicode for us.
return XML.parseString(self.message.get_payload())