本文整理汇总了Python中xml.dom方法的典型用法代码示例。如果您正苦于以下问题:Python xml.dom方法的具体用法?Python xml.dom怎么用?Python xml.dom使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xml
的用法示例。
在下文中一共展示了xml.dom方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import xml [as 别名]
# 或者: from xml import dom [as 别名]
def __init__(self, input_file):
self.dom = minidom.parse(input_file)
self.svg_node = self.dom.documentElement
示例2: import_groups
# 需要导入模块: import xml [as 别名]
# 或者: from xml import dom [as 别名]
def import_groups(self, from_svg_processor):
for child in from_svg_processor.svg_node.childNodes:
if child.nodeType != child.ELEMENT_NODE or child.tagName != 'g':
continue
group = child
output_node = self.dom.importNode(group, True)
self.svg_node.appendChild(output_node)
示例3: wrap_with_group
# 需要导入模块: import xml [as 别名]
# 或者: from xml import dom [as 别名]
def wrap_with_group(self, attrs):
parent = self.svg_node
wrapper = self.dom.createElement("g")
for k,v in attrs.items():
wrapper.setAttribute(k,v)
for child in parent.getElementsByTagName('g'):
parent.removeChild(child)
wrapper.appendChild(child)
parent.appendChild(wrapper)
示例4: IsRootNode
# 需要导入模块: import xml [as 别名]
# 或者: from xml import dom [as 别名]
def IsRootNode(dom,tagName):
rootNodeTagName = dom.documentElement.tagName
if rootNodeTagName == tagName:
return True
else:
return False
#===================== End Of Function <IsRootNode> ===================
### get pairnodes in a list
#================================================
示例5: GenerateClearIntervalCmdlet
# 需要导入模块: import xml [as 别名]
# 或者: from xml import dom [as 别名]
def GenerateClearIntervalCmdlet(xmlString):
doc = xml.dom.minidom.parseString(xmlString)
node = None
topNode = doc.documentElement
if topNode is None:
return
if topNode.localName == "statsClearInterval":
node = topNode
else:
print "Check if Method is <statsClearInterval>"
return
cmdlet = ""
dnNodes = GetElementChildNodes(node.getElementsByTagName("inDns")[0])
if dnNodes is None or len(dnNodes) < 0:
return
cmdlet = "dnSet = DnSet()" + "\n"
tempDn = ""
for dnNode in dnNodes:
tempDn = dnNode.getAttribute(NamingPropertyId.VALUE)
cmdlet += "dn = Dn()\ndn.setattr(\"Value\",\"%s\")\ndnSet.AddChild(dn)\n" %(tempDn)
cmdlet += "handle.ConfigResolveDns(dnSet)"
return cmdlet #04dec
#==================================== End Of Function <GenerateClearIntervalCmdlet> =======================================
#-------------------------------- END - OF - METHOD SPECIFIC - FUNCTION --------------------------------
### check which function to call for a specific method
#======================================================
示例6: GenerateCmdlets
# 需要导入模块: import xml [as 别名]
# 或者: from xml import dom [as 别名]
def GenerateCmdlets(xmlString):
cmdlet = ""
global displayXml, outFilePath
if displayXml:
doc = xml.dom.minidom.parseString(xmlString)
DumpXmlOnScreen(doc)
category = ""
matchFound = re.match(r"^[\s]*<[\s]*([\S]+)", xmlString)
if matchFound:
methodName = matchFound.group(1)
category = methodName
else:
return
if category == "configConfMos" or category == "configConfMo":
cmdlet = GenerateConfigConfCmdlets(xmlString)
elif category in ["configResolveDn","configResolveDns","configResolveClass","configResolveClasses"]:
cmdlet = GenerateConfigResolveCmdlet(xmlString, category)
elif category == "lsClone":
cmdlet = GenerateSingleCloneCmdlets(xmlString, False)
elif category == "lsInstantiateTemplate":
cmdlet = GenerateSingleCloneCmdlets(xmlString, True)
elif category == "lsTemplatise":
cmdlet = GenerateLsTemplatiseCmdlets(xmlString)
elif category == "lsInstantiateNTemplate":
cmdlet = GenerateMultipleCloneCmdlets(xmlString, True)
elif category == "lsInstantiateNNamedTemplate":
cmdlet = GenerateMultipleCloneCmdlets(xmlString, False)
elif category == "statsClearInterval":
cmdlet = GenerateClearIntervalCmdlet(xmlString)
## 04dec: support for redirecting script output to respective file
if outFileFlag:
outFile = open(outFilePath, 'a')
print >> outFile, '##### Start-Of-PythonScript #####'
print >> outFile, cmdlet
print >> outFile, '##### End-Of-PythonScript #####'
outFile.close()
else:
print "##### Start-Of-PythonScript #####"
print cmdlet
print "##### End-Of-PythonScript #####"
return
#===================================== End Of Function <GenerateCmdlets> ==================================
###This Extracts xmlstring from the file and calls the GenerateCmdlets() on this xmlstring.
#======================================================