为什么 Firefox 显示:XML 解析错误:文档元素后的垃圾? [英] Why does Firefox show: XML Parsing Error: junk after document element?
问题描述
错误:
尚未从控制台获得所需的输出:
yet from the console, desired output:
nicholas@mordor:~$
nicholas@mordor:~$ curl http://localhost:8080/exist/rest/db/scripts/notes.xq
<notes>
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
<note>
foo
</note>
<note>
bar
</note>
</notes>
<notes>
<note>
foo
</note>
<note>
bar
</note>
<note>
baz
</note>
</notes>nicholas@mordor:~$
nicholas@mordor:~$
nicholas@mordor:~$ lynx http://localhost:8080/exist/rest/db/scripts/notes.xq --dump
<notes>
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
<note>
foo
</note>
<note>
bar
</note>
</notes>
<notes>
<note>
foo
</note>
<note>
bar
</note>
<note>
baz
</note>
</notes>nicholas@mordor:~$
nicholas@mordor:~$
这就是我正在寻找的来自 Firefox 的输出或类似的输出.
so that's the output I'm looking for, or similar output, from firefox.
FLWOR
:
xquery version "3.0";
for $note in collection('/db/tmp')/notes
return $note
这是我能做到的最简单的.
which is as simple as I could make it.
eXide
从 GUI 控制台返回什么:
what eXide
returns from the GUI console:
<notes>
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
<note>
foo
</note>
<note>
bar
</note>
</notes>
2
<notes>
<note>
foo
</note>
<note>
bar
</note>
<note>
baz
</note>
</notes>
这是我正在寻找的输出.
which is the output I was looking for.
所以也许这更像是浏览器的配置错误最重要的是?
So perhaps this is more an error of configuration from the browser more than anything else?
推荐答案
您在此 XML 文件中有两个
标签.XML 规范规定您可能只有一个根元素.
You have two <notes>…</notes>
tags in this XML file. The XML specification states that you may only have one root element.
要解决此问题,请删除:
To fix this, remove the:
</notes>
<notes>
在文档的中间.这将在单个
标签.
in the middle of the document. That will give you six <note>…</note>
tags inside a single <notes>…</notes>
root.
curl 起作用的原因是它不尝试解析 XML,而只是显示纯文本结果.
The reason that curl works is because it isn’t trying to parse the XML, but just showing the plain text result.
这篇关于为什么 Firefox 显示:XML 解析错误:文档元素后的垃圾?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!