text to xml python code example Example: python string to xml import xml.etree.ElementTree as ET root = ET.fromstring(country_data_as_string)