好的,我有一个要解析的大 xml 文档,所以我可以将它们添加到数据库中。
fileIn = open(path + 'POTS_Table'+ date + '.xml', 'r') ## gets file from location
file = fileIn.read() ## reads all data in file and saves as variable file
parser = etree.XMLParser(recover=True) ## to help with broken xml attributes
tree= etree.parse(fileIn, parser=parser)
只要我打印结果,这工作正常,但是当我尝试
parameters ={treeAttributesDictionary}
update= '''update table set column1:parameters1 '''
change=update.format(**parameters)
c.execute(change)
我得到这个错误
File "./sqltest.py", line 1932, in <module>
main(path,date)
File "./sqltest.py", line 1912, in main
addPots(path,date)
File "./sqltest.py", line 1330, in addPots
tree = ET.fromstring(file, parser=parser) ## parses the information in the XML file , parser=parser
TypeError: XML() got an unexpected keyword argument 'parser'
谁能帮我?