0

I am attempting to deserialize only part of an xml, like in this post - How to deserialize only part of an XML document in C#.

This works, I get an object back!

But, with a validation error of type "... element is not declared".

Sketchy structre of my xml:

<UploadDocument>
  <Document>
    <!-- Inner xml removed-->
  </Document>
</UploadDocument>

And the error message is - Document element is not declared.

If I attempt to deserialize the root element - UploadDocument - it just works with no validation errors.

My observation: When the schema is compiled, the Elements collection has only the root element - UploadDocument.

Social Developer
  • 405
  • 5
  • 16
  • The answer, by MiMo, to the following post worked for me: https://stackoverflow.com/questions/19232065/validating-xml-node-over-a-xsd-file – Social Developer May 31 '17 at 10:00

1 Answers1

0

I have found a fix for this. The code that I have found is this:

<UploadDocument>
<Document>
    <?xml version="1.0" encoding="utf-8" ?>
    <Document>
</UploadDocument>