def _extract_tag_from_xml_data(data, tag_name=b"packet"):
    """Gets data containing a (part of) tshark xml.

    If the given tag is found in it, returns the tag data and the remaining data.
    Otherwise returns None and the same data.

    :param data: string of a partial tshark xml.
    :param tag_name: A bytes string of the tag name
    :return: a tuple of (tag, data). tag will be None if none is found.
    """
    opening_tag = b"<" + tag_name + b">"
    closing_tag = opening_tag.replace(b"<", b"</")
    tag_end = data.find(closing_tag)
    if tag_end != -1:
        tag_end += len(closing_tag)
        tag_start = data.find(opening_tag)
        return data[tag_start:tag_end], data[tag_end:]
    return None, data
Gets data containing a (part of) tshark xml.

    If the given tag is found in it, returns the tag data and the remaining data.
    Otherwise returns None and the same data.

    :param data: string of a partial tshark xml.
    :param tag_name: A bytes string of the tag name
    :return: a tuple of (tag, data). tag will be None if none is found.
    
src/pyshark/tshark/output_parser/tshark_xml.py