In the below function, can you help me add the date of the meeting that is being passed from the xml.

The date is inside the tag "DateOfSitting" at the very beginning of the xml document.

Example:
<Dokument xmlns:ns0="http://FT.PIP.Afskrift.Schemas" edixistatus="Foreløbig">
<MetaMeeting tingdokID="1980944">
<ParliamentarySession tingdokID="200082">20231</ParliamentarySession>
<ParliamentaryGroup tingdokID="528921">Folketinget</ParliamentaryGroup>
<MeetingNumber>100</MeetingNumber>
<DateOfSitting>2024-05-28T13:00:00</DateOfSitting>
<Location>Folketingssalen</Location>
<EdixiDocLocation>W:\20231\M100\</EdixiDocLocation>
<AudioFileFolder>X:\Arbor\FT2023\100\SALEN\</AudioFileFolder>
</MetaMeeting>
<TitelGruppe>
...
</TitelGruppe>
<DagsordenPlan>
...
</DagsordenPlan>
<DagsordenPunkt>

Code (function)


from ftplib import FTP
import xml.etree.ElementTree as ET
import pandas as pd

def parse_referat(filename):  
       # Parse the XML content
        print("Parsing XML content...")
        tree = ET.parse(filename)
        root = tree.getroot()
        
        # Initialize data list
        data = []
        
        # Process each DagsordenPunkt
        for dagsorden in root.findall('.//DagsordenPunkt'):
            # Get MetaFTAgendaItem information
            meta_ft = dagsorden.find('.//MetaFTAgendaItem')
            if meta_ft is not None:
                # Extract required fields
                item_no = meta_ft.find('ItemNo')
                ft_case = meta_ft.find('FTCase')
                ft_case_type = meta_ft.find('FTCaseType')
                short_title = meta_ft.find('ShortTitle')
                
                # Create dictionary for this DagsordenPunkt
                entry = {
                    'ItemNo': item_no.text if item_no is not None else '',
                    'FTCase': ft_case.attrib.get('tingdokID', '') if ft_case is not None else '',
                    'FTCaseType': ft_case_type.text if ft_case_type is not None else '',
                    'ShortTitle': short_title.text if short_title is not None else ''
                }
                
                # Add speakers and their speeches
                speakers = []
                speeches = []
                for talk in dagsorden.findall('.//Tale'):
                    # Get speaker information
                    speaker_elem = talk.find('.//MetaSpeakerMP')
                    if speaker_elem is None:
                        speaker_elem = talk.find('.//Taler')
                    
                    if speaker_elem:
                        first_name = speaker_elem.find('OratorFirstName')
                        last_name = speaker_elem.find('OratorLastName')
                        party = speaker_elem.find('GroupNameShort')
                        
                        speaker = f"{first_name.text} {last_name.text}" if first_name is not None and last_name is not None else ''
                        if party is not None:
                            speaker += f" ({party.text})"
                        
                        speakers.append(speaker)
                        
                        # Get speech content
                        speech = []
                        for segment in talk.findall('.//TekstGruppe'):
                            for exitus in segment.findall('.//Exitus'):
                                for linea in exitus.findall('.//Linea'):
                                    char_elem = linea.find('Char')
                                    if char_elem is not None and char_elem.text is not None:
                                        speech.append(char_elem.text.strip())
                        speeches.append('\n'.join(speech))
                
                # Add speakers and speeches to entry
                entry['Speakers'] = ', '.join(speakers)
                entry['Speeches'] = '\n\n'.join(speeches)
                
                data.append(entry)
        
        # Create DataFrame
        df = pd.DataFrame(data)
        
        # Set display options for better viewing
        pd.set_option('display.max_columns', None)
        pd.set_option('display.max_colwidth', None)
        pd.set_option('display.width', None)
        
        return df