I'm making an automation that takes an existing XML file, changes one of the values and overwrites the file.
My main problem is that its important for me to keep the formatting of the original file and i can't manage to do that, the new data has no line breaks and its all just a long line.
<StationConfig StationId="8706" SportType="null" StationType="null" UseMetricSystem="US" LocalTempStorageDrive="C:\" LocalStorageDrive="C:\">
<ClubManagementEnable ClubManagementStaticHours="">false</ClubManagementEnable>
</StationConfig>
My code is:
parser = etree.XMLParser()
read = etree.parse("C:\StationConfig.xml", parser=parser).getroot()
read.set("StationId", "8706")
tree = etree.ElementTree(read)
tree.write("C:\devtree\Station.xml", pretty_print=True)
How can i add an \n after each element? Thanks!