Why does Firefox show: XML Parsing Error: junk after document element?

限于喜欢 提交于 2021-02-11 14:22:57

问题


Error:

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:~$ 

so that's the output I'm looking for, or similar output, from firefox.

The FLWOR:

xquery version "3.0";

for $note in collection('/db/tmp')/notes
return $note

which is as simple as I could make it.

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?


回答1:


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.

The reason that curl works is because it isn’t trying to parse the XML, but just showing the plain text result.



来源:https://stackoverflow.com/questions/64950252/why-does-firefox-show-xml-parsing-error-junk-after-document-element

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!