The input as a string.
If the input is undefined, immediately return undefined. This makes it easy to propagate errors and only check for undefined once, at the end.
The root element of the resulting XML Document, or undefined in case of any errors.
This is my preferred way to parse an XML document. Any and all errors result in
undefined
.See testXml()
if you need better error messages.