I been looking at XML Serialization for C# and it looks interesting. I was reading this tutorial
http://www.switchonthecode.com/tutorials/csharp-tutorial-xml-serialization
and of course you can de serialize it back to a list of objects. So I am wondering would it be better to de serialize it back to to a list of objects and then go through each object and validate it or validate it by using a schema then de serializing it and doing stuff with it?
http://support.microsoft.com/kb/307379
Thanks
I guess it would depend a bit on what you want to validate, and for what purpose. If it is intended for interop to other systems, then validating via xsd is a reasonable idea not least because you can use
xsd.exeto write your classes for you from the xsd (you can also generate xsd from xml or dll, but it isn’t as accurate). Likewise you can useXmlReader(appropriately configured) to check against xsd,If you just want valid .NET objects, I’d be tempted to leave the serialized form as an implementation detail, and write some C# validation code – perhaps implementing
IDataErrorInfo, or using data-annotations.