Python:读取一个非常大的XML文件

时间:2017-12-27 17:13:26

标签: python xml

我试图从python脚本中读取一个xml文件(这是一个法语词典),但是我收到了以下错误。无论如何我能解决它吗? PS:文件是158 643 Ko

from xml.dom import minidom
doc = minidom.parse("Dic.xml")

Data = doc.getElementsByTagName("title")[0]
titleData = Data.firstChild.data
print (titleData)

错误:

Traceback (most recent call last):
  File "<pyshell#3>", line 1, in <module>
    doc = minidom.parse("Morphalou-2.0.xml")
  File "C:\Python27\lib\xml\dom\minidom.py", line 1918, in parse
    return expatbuilder.parse(file)
  File "C:\Python27\lib\xml\dom\expatbuilder.py", line 924, in parse
    result = builder.parseFile(fp)
  File "C:\Python27\lib\xml\dom\expatbuilder.py", line 204, in parseFile
    buffer = file.read(16*1024)
MemoryError

提前谢谢

0 个答案:

没有答案