I have the following text file:
"POLYGON ((7529 4573, 7541 4573, 7565 4577, 7586 4580, 7607 4584, 7633 4586, 7649 4591, 7675 4594, 7708 4600, 7758 4612))"
I would like to convert it to the following format:
"<Vertices><V X="7529" Y="4573" /><V X="7541" Y="4573" /><V X="7565" Y="4577" /><V X="7586" Y="4580" /><V X="7607" Y="4584" /><V X="7708" Y="4586" /><V X="7649" Y="4591" /><V X="7675" Y="4594" /><V X="13278" Y="4600" /><V X="7758" Y="4612" />
What I tried so far?
from xml.etree.ElementTree import Element, SubElement, tostring
top = Element('Vertices')
child = SubElement(top, 'V')
child.text = "POLYGON ((7529 4573, 7541 4573, 7565 4577, 7586 4580, 7607 4584, 7633 4586, 7649 4591, 7675 4594, 7708 4600, 7758 4612))"
print(tostring(top))
How can I add the x and y co-ordinates to the XML output?