当前位置: 首页>>代码示例>>Python>>正文


Python xml.dom方法代码示例

本文整理汇总了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 
开发者ID:productize,项目名称:kicad-automation-scripts,代码行数:5,代码来源:svg_processor.py

示例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) 
开发者ID:productize,项目名称:kicad-automation-scripts,代码行数:9,代码来源:svg_processor.py

示例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) 
开发者ID:productize,项目名称:kicad-automation-scripts,代码行数:13,代码来源:svg_processor.py

示例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
#================================================ 
开发者ID:CiscoUcs,项目名称:UcsPythonSDK,代码行数:12,代码来源:WatchUcsGui.py

示例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
#====================================================== 
开发者ID:CiscoUcs,项目名称:UcsPythonSDK,代码行数:41,代码来源:WatchUcsGui.py

示例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.
#====================================================== 
开发者ID:CiscoUcs,项目名称:UcsPythonSDK,代码行数:50,代码来源:WatchUcsGui.py


注:本文中的xml.dom方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。