I was wondering if in an xml file I could launch a python file and based on what python returns run different parts of the xml code.
Something like
IN THE XML FILE:

run the python file
if the file retuns A, run the A code of this XML file
else run the B code of this XML file

thanks!
An XML file can't run a python script since XML is a descriptive language used to represent data.
However you can do the opposite, that's to say, use python to read the XML file and do something.
By the way when you say "run the A code of this XML file", i'm not sure you're doing it right, since XML is not supposed to contain "active code".
launch python file from an xml file