Load an XML document into a DOM document.
A document type declaration (DOCTYPE) declares entities, which the
parser expands where the document references them: nested internal
entities make a small document expand into gigabytes ("billion
laughs"), and external entities read files or URLs. An XML token never
has one, so a document holding the bytes <!DOCTYPE is refused before
it is parsed, whatever it declares. This check reads the raw bytes: it
only holds for an encoding in which <!DOCTYPE can only be written as
these very bytes, which is why a document is also refused, before it is
parsed, when it is not in UTF-8, the encoding of the tokens: one that
holds a NUL byte (UTF-16, UTF-32), that declares another encoding, or
that does not start with < (EBCDIC, among others). The parsed document is refused too
if it has a document type node, should the check above miss one.
The document is parsed with LIBXML_NONET: the parser never accesses
the network. Any libxml error refuses the document, and none is output.
Whitespace is preserved: digests are computed over the document as it
was signed.