问题
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