Commits

Gaurav Toshniwal committed f173fae

xml updated

Comments (0)

Files changed (2)

 <?xml version="1.0" ?>
 <MchDtl AwTm="New Zealand" AwTmId="5" Evt="New Zealand in West Indies, 2 Test Series, 2012" HmTm="West Indies" HmTmId="9" LsUpDt="7/30/2012" LsUpTm="1:56:56 AM" MchId="92854" Vnu="Sir Vivian Richards Stadium, Antigua">
-  <CrtInns>
+  <CrtInns AltdOvs="46" BtTm="West Indies" BtTmId="9" BwTm="New Zealand" BwTmId="5" Trg="102">
     <Det Ovs="19.3" RR="5.23" Tot="102" Wkts="1"/>
     <Bats>
       <Bat Bls="49" BtId="1201" Rn="64">
 
 matchdetail = soup.findAll('Matchdetail')
 
-current_inning_key = {
+current_inning_prefix = {
 	'First' : 'FI',
 	'Second': 'SI',
 	'Third' : 'TI',
 	'Fourth': 'FOI',
 }
-batsmen = soup.findAll(current_inning_key[matchdetail[0]['currentinning']]+'Batsman',Howout='not out')
+current_inning_key = {
+	'First' : 'FirstInnings',
+	'Second': 'SecondInnings',
+	'Third' : 'ThirdInnings',
+	'Fourth': 'FourthInnings',
+}
+
+batsmen = soup.findAll(current_inning_prefix[matchdetail[0]['currentinning']]+'Batsman',Howout='not out')
 soup.findAll(Bowling="Yes")
 
 #create xml document structure
 for key in Matchdetail_attrs:
 	Matchdetail.setAttribute(Matchdetail_attrs[key],matchdetail[0][key])
 
+currentinning = soup.findAll(current_inning_key[matchdetail[0]['currentinning']])
 Currentinnings = doc.createElement("CrtInns")
 Matchdetail.appendChild(Currentinnings)
+for key in Currentinnings_attrs:
+	Currentinnings.setAttribute(Currentinnings_attrs[key],currentinning[0][key])
 
 foiequation = soup.findAll('FOIEquation')
 FOIEquation = doc.createElement("Det")
 Currentinnings.appendChild(Currentbowlers)
 Currentbowlers.appendChild(doc.createTextNode(''))
 
-f=open('score.xml','r+')
+try:
+	f=open('score.xml','r+')
+except:
+	f=open('score.xml','w')
 f.write(doc.toprettyxml(indent="  "))
 f.close()
-print doc.toprettyxml(indent="  ")
+#print doc.toprettyxml(indent="  ")