Hey All,
am looking for a way to break an xml Tag line into tag and attributes. Say I have This line
<event time="12:30" value="This is a Sample Value" type="event">
</event>
I have this so far
# Open file to read
f=open("myTest2.xml")
#start reading File
for line in f:
linestart=line.find("<")
newline=line[linestart:len(line)]
#check for XML version
if newline[0:2] == "<?":
print "XML version Line : "+newline
#get start tag
if newline[0:1] == "<" and newline[1:2] != "?":
x=newline.find(" ")
y=newline.find(">")
if str(x) == "-1" :
temp=newline[1:y]
else:
temp = newline[1:x]
#get attribute list
attributeList = newline[x:len(newline)-2]
print attributeList.split(" ")
This bears:
I want to get:
Thanks in advance for any replies.