相当打印xml文件时出现Parser.pxi问题

时间:2015-02-18 11:01:18

标签: python xml python-2.7 lxml

当我试图打印一个xml文件时,我遇到了一些错误。我到处寻找并尝试安装最新版本的lxml但仍然出现此错误。

我的脚本非常简单,看起来像这样。

import os
import lxml.etree as etree
from lxml.etree import parse
fname = 'C:\Test_folder\SlutR_20150218.xml'
x = etree.parse(fname)
print etree.tostring(x, pretty_print = True)

我得到的错误正在跟随。

Traceback (most recent call last):
File  "C:\Users\a.curcic\Desktop\Övriga_python_script\
Pretty_print_example.py", 
line   5, in <module> x = etree.parse(fname)
File "lxml.etree.pyx", 
line 3301, in lxml.etree.parse      
(src\lxml\lxml.etree.c:72453) 
File "parser.pxi", line 1791, in lxml.etree._parseDocument  
(src\lxml\lxml.etree.c:105915)
File "parser.pxi", line 1817, 
in lxml.etree._parseDocumentFromURL (src\lxml\lxml.etree.c:106214)
XMLSyntaxError: 
Extra content at the end of the document, line 2, column 909

0 个答案:

没有答案