Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x 如何使用Beauty soup解析大XML文件?_Python 3.x_Beautifulsoup - Fatal编程技术网

Python 3.x 如何使用Beauty soup解析大XML文件?

Python 3.x 如何使用Beauty soup解析大XML文件?,python-3.x,beautifulsoup,Python 3.x,Beautifulsoup,我正试图解析一个名为document.XML的XML文件,该文件包含大约400000个字符(包括标记、特征线、空格),请在下面查找代码 document_xml_file_object = open('document.xml', 'r') document_xml_file_content = document_xml_file_object.read() xml_content = BeautifulSoup(document_xml_file_content, 'lxml-xml') p

我正试图解析一个名为
document.XML
的XML文件,该文件包含大约400000个字符(包括标记、特征线、空格),请在下面查找代码

document_xml_file_object = open('document.xml', 'r')
document_xml_file_content = document_xml_file_object.read()

xml_content = BeautifulSoup(document_xml_file_content, 'lxml-xml')
print("XML CONTENT: ", xml_content)
当我打印
xml\u内容时,下面是我的输出:

XML CONTENT:  <?xml version="1.0" encoding="utf-8"?>
XML内容:
对于较小大小的文件,它可以打印完整的XML代码。有人能帮我解释一下为什么会这样吗

编辑:查看我的XML内容


提前感谢

对于大文件,最好使用类似的行分析器
beautifulsoup
将在内存中加载整个文件并进行解析,同时使用
xml。sax
将使用更少的内存。

请共享xml文件的内容。抱歉,它的机密文件包含敏感信息。我无法共享该文件,但它完全修饰了docx文件的document.xml文件。否则很难回答。@JackFleeting我已将pastebin链接添加到问题中,请查找文件。@MendelG我已将pastebin链接添加到问题中,请查找文件。