'Return a name,value pair for the next attribute in the stream,
if one is found, or None'

def getAttribute(self):

    data = self.data
    c = data.skip((spaceCharactersBytes | frozenset(['/'])))
    assert ((c is None) or (len(c) == 1))
    if (c in ('>', None)):
        return None
    attrName = []
    attrValue = []
    while True:
        if ((c == '=') and attrName):
            break
        elif (c in spaceCharactersBytes):
            c = data.skip()
            break
        elif (c in ('/', '>')):
            return (''.join(attrName), '')
        elif (c in asciiUppercaseBytes):
            attrName.append(c.lower())
        elif (c is None):
            return None
        else:
            attrName.append(c)
        c = next(data)
    if (c != '='):
        data.previous()
        return (''.join(attrName), '')
    next(data)
    c = data.skip()
    if (c in ("'", '"')):
        quoteChar = c
        while True:
            c = next(data)
            if (c == quoteChar):
                next(data)
                return (''.join(attrName), ''.join(attrValue))
            elif (c in asciiUppercaseBytes):
                attrValue.append(c.lower())
            else:
                attrValue.append(c)
    elif (c == '>'):
        return (''.join(attrName), '')
    elif (c in asciiUppercaseBytes):
        attrValue.append(c.lower())
    elif (c is None):
        return None
    else:
        attrValue.append(c)
    while True:
        c = next(data)
        if (c in spacesAngleBrackets):
            return (''.join(attrName), ''.join(attrValue))
        elif (c in asciiUppercaseBytes):
            attrValue.append(c.lower())
        elif (c is None):
            return None
        else:
            attrValue.append(c)
