def find_xmlattrs(files):
    """
    This function scans a set of XML documents and identifies all of
    the element attributes for later fuzzing. The XML documents are
    given in a list of dicts, each having a ``data`` field and any
    number of other user defined fields to identify the file.

    The result is a list of opaque objects identifying the fuzzable
    attributes, which should be used as input to :func:`fuzz_xmlattrs`.
    """
    attributes = []
    for fileid, f in enumerate(files):
        file_data = f["data"]
        if file_data.startswith("<?"):
            off = file_data.find("?>") + 2
        else:
            off = 0
        try:
            while True:
                # find the next element starting with '<' (st) and ending with '>' (en)
                st = file_data.index("<", off)
                en = file_data.index(">", st)
                off = en + 1

                # find a space within the element
                sp = file_data.find(" ", st, en)
                if sp == -1:
                    continue

                # extract element name
                # (don't really need this, don't bother for now)
                element = file_data[st+1:sp]
                sp += 1

                # find all the attributes within this element
                while True:
                    # find the start and end of the value
                    try:
                        eq = file_data.index("=\"", sp, en)
                        name = file_data[sp:eq] # extract the attribute name
                        stq = eq + 2 # first char in the value (start quote)
                        enq = file_data.index("\"", stq, en) # end quote pos
                    except ValueError:
                        break
                    val = file_data[stq:enq] # extract the attribute value
                    sp = enq + 2 # move sp past the end of the end quote
                    # skip xml namespace attributes
                    if name.startswith("xmlns"):
                        continue
                    # cascade through the try blocks to find what kind of value this is
                    try:
                        val = FuzzableInteger(val)
                    except ValueError:
                        # leave val as a string if we can't create a FuzzableInteger from it
                        pass
                    # got everything, add to the result list
                    attributes.append(XmlFuzzableAttribute(name, val, element, fileid, stq, enq))
        except __HOLE__:
            pass
    return attributes
dataset/ETHPy150Open blackberry/ALF/alf/fuzz/XmlAttributeFuzz.py/find_xmlattrs