def encodeXMLName(namespace, name):
    """
    Encodes an XML namespace and name into a UTF-8 string.
    If namespace is None, returns "name", otherwise, returns
    "{namespace}name".
    """
    if not namespace:
        sname = name
    else:
        sname = u"{%s}%s" % (namespace, name)

    return sname.encode("utf-8")