[英]xml.etree.ElementTree.ParseError: junk after document element
I'm trying to install CESM2 and while trying to create a new case I receive this error:我正在尝试安装 CESM2,并在尝试创建新案例时收到此错误:
File "/usr/lib64/python3.6/xml/etree/ElementTree.py", line 1196, in parse tree.parse(source, parser) File "/usr/lib64/python3.6/xml/etree/ElementTree.py", line 597, in parse self._root = parser._parse_whole(source) xml.etree.ElementTree.ParseError: junk after document element: line 211, column 2
When I traced back line 211 in ElementTree.py, it contains this function:当我在 ElementTree.py 中追溯第 211 行时,它包含这个 function:
def __bool__(self):
warnings.warn(
"The behavior of this method will change in future versions. "
"Use specific 'len(elem)' or 'elem is not None' test instead.",
FutureWarning, stacklevel=2
)
return len(self._children) != 0 # emulate old behaviour, for now
Can anyone please suggest how to resolve this?谁能建议如何解决这个问题?
The indicated position ( line 211, column 2 ) refers to the source file being parsed, not the line in your code.指示的 position (第 211 行,第 2 列)是指正在解析的源文件,而不是代码中的行。
When parsing XML file, it should contain a single element at the top level.解析 XML 文件时,它应该在顶层包含一个元素。 Apparently your source XML is malformed.
显然您的源 XML 格式不正确。
Sometimes a solution in this case is to "wrap" the whole content with a single "root" element.有时,这种情况下的解决方案是用单个“根”元素“包装”整个内容。 At least this parsing error should disappear, but note that it changes the output XML tree, compared to the original intention, so maybe some XPath expressions should be also changed.
至少这个解析错误应该消失了,但是注意它改变了 output XML 树,与初衷相比,所以可能一些 XPath 表达式也应该改变。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.