]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Tools/Python/XmlRoutines.py
Change parameter id in UserExtension element from Integer to String according to...
[mirror_edk2.git] / Tools / Python / XmlRoutines.py
index 0345f4acc645bc6fc533a0c3aa2aa3c682dbff5b..3ffb84700988947035ab0a5924a54ef95ec40855 100755 (executable)
@@ -73,6 +73,13 @@ def XmlParseFile (FileName):
   except:
     return xml.dom.minidom.parseString('<empty/>')
 
+def XmlParseString (Str):
+  """Parse an XML string into a DOM and return the DOM."""
+  try:
+    return xml.dom.minidom.parseString(Str)
+  except:
+    return xml.dom.minidom.parseString('<empty/>')
+
 def XmlParseFileSection (FileName, Tag):
   """Parse a section of an XML file into a DOM(Document Object Model) and return the DOM."""
   try:
@@ -136,14 +143,14 @@ def XmlAppendChildElement(ParentNode, TagName, ElementText='', AttributeDictiona
   """Add a child element to a DOM(Document Object Model) tree with optional Attributes."""
   TagName = TagName.strip()
   if TagName == '':
-    return False
+    return None
   Depth = 0
   Dom = ParentNode
   while Dom != None and Dom.nodeType != Dom.DOCUMENT_NODE:
     Dom = Dom.parentNode
     Depth += 1
   if Dom == None:
-    return False
+    return None
   ParentNode.appendChild(Dom.createTextNode('\n%*s' % (Depth * 2, '')))
   ElementNode = Dom.createElement(TagName)
   if ElementText != '':
@@ -151,7 +158,7 @@ def XmlAppendChildElement(ParentNode, TagName, ElementText='', AttributeDictiona
   for Item in AttributeDictionary:
     ElementNode.setAttribute(Item, AttributeDictionary[Item])
   ParentNode.appendChild(ElementNode)
-  return True
+  return ElementNode
   
 
 # This acts like the main() function for the script, unless it is 'import'ed into another