mirror of
https://github.com/acidanthera/audk.git
synced 2025-07-31 01:24:12 +02:00
Changing XmlAppendChildElement to return the new XML node on success.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2289 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
c7c02fabf1
commit
f0a3fde160
@ -143,14 +143,14 @@ def XmlAppendChildElement(ParentNode, TagName, ElementText='', AttributeDictiona
|
|||||||
"""Add a child element to a DOM(Document Object Model) tree with optional Attributes."""
|
"""Add a child element to a DOM(Document Object Model) tree with optional Attributes."""
|
||||||
TagName = TagName.strip()
|
TagName = TagName.strip()
|
||||||
if TagName == '':
|
if TagName == '':
|
||||||
return False
|
return None
|
||||||
Depth = 0
|
Depth = 0
|
||||||
Dom = ParentNode
|
Dom = ParentNode
|
||||||
while Dom != None and Dom.nodeType != Dom.DOCUMENT_NODE:
|
while Dom != None and Dom.nodeType != Dom.DOCUMENT_NODE:
|
||||||
Dom = Dom.parentNode
|
Dom = Dom.parentNode
|
||||||
Depth += 1
|
Depth += 1
|
||||||
if Dom == None:
|
if Dom == None:
|
||||||
return False
|
return None
|
||||||
ParentNode.appendChild(Dom.createTextNode('\n%*s' % (Depth * 2, '')))
|
ParentNode.appendChild(Dom.createTextNode('\n%*s' % (Depth * 2, '')))
|
||||||
ElementNode = Dom.createElement(TagName)
|
ElementNode = Dom.createElement(TagName)
|
||||||
if ElementText != '':
|
if ElementText != '':
|
||||||
@ -158,7 +158,7 @@ def XmlAppendChildElement(ParentNode, TagName, ElementText='', AttributeDictiona
|
|||||||
for Item in AttributeDictionary:
|
for Item in AttributeDictionary:
|
||||||
ElementNode.setAttribute(Item, AttributeDictionary[Item])
|
ElementNode.setAttribute(Item, AttributeDictionary[Item])
|
||||||
ParentNode.appendChild(ElementNode)
|
ParentNode.appendChild(ElementNode)
|
||||||
return True
|
return ElementNode
|
||||||
|
|
||||||
|
|
||||||
# This acts like the main() function for the script, unless it is 'import'ed into another
|
# This acts like the main() function for the script, unless it is 'import'ed into another
|
||||||
|
Loading…
x
Reference in New Issue
Block a user