1 Star 0 Fork 0

Christina-long/tuples

Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
This repository doesn't specify license. Please pay attention to the specific project description and its upstream code dependency when using it.
Clone or Download
parseXML.py 1.47 KB
Copy Edit Raw Blame History
import xml.dom.minidom
import xlwt
if __name__=='__main__':
xml_path = "C:/Users/NewUser/Desktop/auto_ELV_Test_Cases.xml"
dom = xml.dom.minidom.parse(xml_path)
db = dom.documentElement
row_element = db.getElementsByTagName('row')
row_num = row_element.length
row = 0
for i in range(0, row_num):
xls = xlwt.Workbook()
sheet = xls.add_sheet('sheet1', cell_overwrite_ok=True)
row = 0
module = row_element[i].getElementsByTagName('module')[0].firstChild.data
if "342" in str(module):
id = row_element[i].getElementsByTagName('id')[0].firstChild.data
stepDesc = row_element[i].getElementsByTagName('stepDesc')[0].firstChild.data
expectDesc = row_element[i].getElementsByTagName('stepExpect')[0].firstChild.data
stepList = stepDesc.replace('\n', '').replace('。', '').replace(' ', '').split('<br/>')
expectList = expectDesc.replace('\n', '').replace('。', '').replace(' ', '').split('<br/>')
leng = len(stepList)
for j in range(0, leng - 1):
step = stepList[j].split('.')[1]
stepArray = step.split(',')
for stepUnit in stepArray:
sheet.write(row, 0, str(stepUnit))
row = row + 1
row = row - 1
sheet.write(row, 1, str(expectList[j]))
row = row + 1
xls.save('caseDirectory/testCase_' + id + '.xls')
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/christinalong/tuples.git
git@gitee.com:christinalong/tuples.git
christinalong
tuples
tuples
master

Search