本文整理匯總了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.
#======================================================