I am using Python to batch edit many musicXML files that currently look like this:
<score-partwise>
...
<attributes>
<transpose>
<diatonic>-5</diatonic>
<chromatic>-9</chromatic>
</transpose>
</attributes>
...
</score-partwise>
How can I add <octave-change>-1</octave-change>
in <transpose></transpose>
, as below?
<score-partwise>
...
<attributes>
<transpose>
<diatonic>-5</diatonic>
<chromatic>-9</chromatic>
<octave-change>-1</octave-change>
</transpose>
</attributes>
...
</score-partwise>
I have attempted this:
import xml.etree.ElementTree as ET
attributes = ET.Element("attributes")
attributes.append(ET.fromstring('<transpose><octave-change>-1</octave-change></transpose>'))
without success.
Any help is very much appreciated. Thank you.