Root element is missing
The input has no element at all.
Root element is missing.
Why it happens
- An empty file, string or response.
- A
Streamwhose position is at its end: written to aMemoryStreamand read back withoutPosition = 0.
How to fix it
Check the length of the input; for a stream you have just written, set stream.Position = 0 before loading it.
.NET throws an XmlSchemaValidationException at the first schema error unless XmlReaderSettings.ValidationEventHandler is set, which then receives every one with its line and position. A well-formedness error is an XmlException and ends reading whatever the settings.
The same problem in xmlvalid
xmlvalid validates with libxml2, which reports it as Document is empty. It checks the whole document in your browser and lists every schema error with its line and column, not only the first.
Document is empty
Example
(an empty file)
<note/>