xmllint doesn't work with https - warning: failed to load external entity
Asked Answered
D

2

16

xmllint does work fine with http://somesite.xml

But it doesn't work with https://somesite.xml

xmllint https://somesite.xml
warning: failed to load external entity "https://somesite.xml"
Dobbin answered 27/7, 2016 at 2:44 Comment(4)
I seem to be having the same problem.Fixity
The same. xmllint doesn't works with DTD on HTTPS.Fincher
If the schema you're using a remote DTD the only workaround I've been able to figure out was to download the DTD locally and replace the schema file with something like: schemaLocation="file:///tmp/my-path.xsd"Rennes
"xmllint doesn't support HTTPS and probably never will." according to gitlab.gnome.org/GNOME/libxml2/-/issues/160Pantsuit
G
3

As a workaround, you could use another utility like curl or wget to download the file first, then pipe it to xmllint.

curl --silent "https://somesite.xml" | xmllint -

Notes:

  • Use - ("hyphen/minus") for xmllint's filename argument to get its XML input from the standard input stream instead of from a file or URL.
  • You might want to use --silent (-s) to suppress curl progress/error messages, to prevent those from being parsed by xmllint.
  • Quotes might be required around the URL if it contains special characters.

This should work for xmllint's XML input over HTTPS, but not sure about a DTD or schema; you might need to download that to a local file first, using a separate curl or wget command.

Granthem answered 20/4, 2020 at 6:41 Comment(1)
This workaround does not really work for XML schema validation with schemas that have imports using HTTPS in their schemaLocation. Only one single schema file can be provided using the --schema parameter. The only workaround for that would be to download all imported schemas and modify their schemaLocation to relative URLs.Pantsuit
P
0

It is not directly a replacement for xmllint as a command-line tool, but the VS Code XML plugin supports automatic downloading of XML schemas via HTTPS.

Pantsuit answered 2/2 at 11:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.