<jupyter_start><jupyter_text>Editing XML Upload all the files from the directory<jupyter_code>directory_path = '/media/auv/Untitled/200510_PMFS/Dive03_DaisyBank/Annotations/*.xml'
files = glob.glob(directory_path)<jupyter_output><empty_output><jupyter_text>Iterate over all the files and make the necessary changes into xml through root.<jupyter_code>for file in files:
    et = xml.etree.ElementTree.parse(file)
    root = et.getroot()
    for obj in root.findall('object'):
        name = obj.find('name')
        if name.text == 'sponge':
            print(file)
            print(name.text)
            # remove object of the root
            #root.remove(obj)
    #et.write(file)<jupyter_output><empty_output><jupyter_text>Testing code<jupyter_code>tes_path = '/media/auv/Untitled/200510_PMFS/Dive03_DaisyBank/Annotations/CCXC.20051018.15084692.0418.xml'
# Open original file
test = xml.etree.ElementTree.parse(tes_path)
test_root = test.getroot()
root.tag
root.attrib
for child in root:
    print(child.tag, child.attrib)
for obj in test_root.findall('object'):
    name = obj.find('name')
    print(name)
    print(obj[0].text)
    if name.text == 'w':
        print(name)
        test_root.remove(obj)
test.write('output.xml')
for ele in et.iterfind('annotation/object'):
    name = ele.findtext('name')
    print(name)
for name in root.iter('name'):
    print(name.text)<jupyter_output>fish
{'fraction_non_alphanumeric': 0.12651894210150108, 'fraction_numerical': 0.02644746247319514, 'mean_word_length': 3.895104895104895, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '448308', 'license': 'MIT', 'n_tokens_mistral': 518, 'n_tokens_neox': 489, 'n_words': 93, 'path': 'Modify_xml.ipynb', 'repo_name': 'sahilghanghas/Utils', 'size': '1399'}