codechewer
asked on
How do I validate XML against schema during serialization
i know how to validate an xml file against a schema during deserialization. i have been searching the internet for an example of serialization validation and have found none. is this possible in c#? any help will be greatly appreciated.
I think xml schema validation occurs during serialization.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I wanted to validate my xml document while in the process of serializing the class into the xml document.
Though the classes were created from the schema, there are some conditions that made the serialized xml document not conform to the xsd structure and data-type requirement.
I did not want to finish serializing the class into an xml document and then attempt to re-read it into memory just for the purpose of validating the document against the schema.
but I found out that you can only validate an xml document by reading the outputed xml document back into memory and there and then only can you validate the document against its schema to discover errors in the document if any.
Unless there is a smarter way of validating the xml string during the process of serializing the class into the xml file, i will close this question and award the points to redpipe who pointed me to the only method i know for validating an xml document against its schema.
Though the classes were created from the schema, there are some conditions that made the serialized xml document not conform to the xsd structure and data-type requirement.
I did not want to finish serializing the class into an xml document and then attempt to re-read it into memory just for the purpose of validating the document against the schema.
but I found out that you can only validate an xml document by reading the outputed xml document back into memory and there and then only can you validate the document against its schema to discover errors in the document if any.
Unless there is a smarter way of validating the xml string during the process of serializing the class into the xml file, i will close this question and award the points to redpipe who pointed me to the only method i know for validating an xml document against its schema.
This question has been classified as abandoned and is being closed as part of the Cleanup Program. See my comment at the end of the question for more details.