def createAppendElement(self, namespaceURI, localName, prefix=None):
declare = False<EOL>qualifiedName = localName<EOL>if namespaceURI:<EOL><INDENT>try:<EOL><INDENT>prefix = self.getPrefix(namespaceURI)<EOL><DEDENT>except:<EOL><INDENT>declare = True<EOL>prefix = prefix or self._getUniquePrefix()<EOL><DEDENT>if prefix: <EOL><INDENT>qualifiedName = '<STR_LIT>' %(prefix, localName)<EOL><DEDENT><DEDENT>node = self.createElementNS(namespaceURI, qualifiedName)<EOL>if declare:<EOL><INDENT>node._setAttributeNS(XMLNS.BASE, '<STR_LIT>' %prefix, namespaceURI)<EOL><DEDENT>self._appendChild(node=node._getNode())<EOL>return node<EOL>
Create a new element (namespaceURI,name), append it
           to current node, and return the newly created node.
        Keyword arguments:
            namespaceURI -- namespace of element to create
            localName -- local name of new element
            prefix -- if namespaceURI is not defined, declare prefix.  defaults
                to 'ns1' if left unspecified.