"""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 != '':
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