in a .xml file?
I\'m a beginner programmer and I\'m stuck on this possibly easy problem: I want to automatically add numbers to the sentences contained in the P tags of an .xml file. So a sampl
Something like this (very untested) might work
import xml.etree.ElementTree as ET
tree = ET.parse(XML_FILE)
root = tree.getroot()
for p in root.iter('p'):
sentences = p.text.split('.')
p.text = ".".join([("<sup>%i<sup>" % count) + sentence for count, sentence in enumerate(sentences)])
tree.write(XML_FILE)