Function to parse an XML and find specific regex considering the size attribute of the document
Mixed languages

Regardless of one's opinion on whether English is the lingua franca of programming, mixing languages is a bad idea. This would be better in all-Italian (where possible; libraries are still in English) or all-English than a mixture.

Type hints

Use them; for instance

def get_xml_by_tag_names(xml_path: str, tag_name_1: str, tag_name_2: str) -&gt; dict:


Unused variable

Here:

l = []


Items iteration

for k in dizionario:
    for v in dizionario[k]:


should be

for k, values in dizionario.items():
    for v in values:


Magic numbers

Move this:

"7.489"


to a named constant variable somewhere.

Multiple replacement

This:

    for to_remove in (" &lt; ", " &gt;", ".", ",", ";", "-", "!", ":", "’", "?", "&lt;&gt;"):


would be easier as a single regular expression and a single call to sub.

Intermediate list

values = [x for x in dict_fasi.values()]
myxml_fasi = ' '.join(values)


can just be

myxml_fasi = ' '.join(dict_fasi.values())