Is it possible to put a Python output into an XML?
The code I have so far is:
with open('logfile.txt', 'r') as StationLog:
for line in StationLog:
header = line.split('=')[0]
if line.split('=')[0].strip() == 'name':
name = line.split('=')[1].strip().lower()
print name
elif line.split('=')[0].strip() == 'siteIP':
siteIP = line.split('=')[1].strip().rstrip('"').lstrip('"')
print siteIP
elif line.split('=')[0].strip() == 'id':
id = line.split('=')[1].strip()
print id
The ouput is:
abcd
192.168.1.1
123
My desired input is:
<Station>
<name>abcd</name>
<siteIP>192.168.1.1</siteIP>
<id>123</id>
</Station>