Python xml.dom() Examples
The following are 6
code examples of xml.dom().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
xml
, or try the search function
.
Example #1
Source File: svg_processor.py From kicad-automation-scripts with Apache License 2.0 | 5 votes |
def __init__(self, input_file): self.dom = minidom.parse(input_file) self.svg_node = self.dom.documentElement
Example #2
Source File: svg_processor.py From kicad-automation-scripts with Apache License 2.0 | 5 votes |
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)
Example #3
Source File: svg_processor.py From kicad-automation-scripts with Apache License 2.0 | 5 votes |
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)
Example #4
Source File: WatchUcsGui.py From UcsPythonSDK with Apache License 2.0 | 5 votes |
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 #================================================
Example #5
Source File: WatchUcsGui.py From UcsPythonSDK with Apache License 2.0 | 5 votes |
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 #======================================================
Example #6
Source File: WatchUcsGui.py From UcsPythonSDK with Apache License 2.0 | 4 votes |
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. #======================================================