Numbering The Sentences Inside A
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 sample par
Solution 1:
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)
Post a Comment for "Numbering The Sentences Inside A
In A .xml File?"