Is an undeclared prefix
An element or attribute uses a namespace prefix that no xmlns declaration defines.
'inv' is an undeclared prefix. Line 1, position 2.
Why it happens
- A missing or misplaced
xmlns:prefix="…"declaration. - A fragment taken out of a larger document without the namespace declarations of its ancestors.
How to fix it
Declare the prefix on the element or an ancestor, usually the root, with the namespace the format defines. When extracting a fragment, write it with XElement or XmlWriter, which add the declarations it needs.
.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 Namespace prefix is not defined. It checks the whole document in your browser and lists every schema error with its line and column, not only the first.
Namespace prefix inv on invoice is not defined
Example
<inv:invoice/>
<inv:invoice xmlns:inv="urn:example:invoice"/>