def createNode(node, text):
    """ Create a child text node """
    root = node
    while root.nodeType != root.DOCUMENT_NODE:
        root = root.parentNode
    node.appendChild(root.createTextNode(text))
    return node
