Try this (untested): // Load document XDocument doc = XDocument. Visual Studio, when I open the file, validates it against the schema and lists errors perfectly. I expect to fail validation against DCL.xsd, but the validation is OK, not fail. I expect to fail validation against DCL.xsd, but the validation is OK, not fail.Somehow, though, I can't seem to validate it automatically in C# without specifying the schema to validate against like so: Xml Document asset = new Xml Document(); Xml Text Reader schema Reader = new Xml Text Reader("relative Schema Path"); Xml Schema schema = Xml Schema. I try using 7 several methods for validate XML using XSD, but all fails for me. I try using 7 several methods for validate XML using XSD, but all fails for me.
The exception is caused by the fact that you cannot specify a prefix in a call to Attributes; you need to specify the desired XNamespace.Checks whether the current node is a content (non-white space text, CDATA, Element, End Element, Entity Reference, or End Entity) node.If the node is not a content node, the reader skips ahead to the next content node or end of file.If external document type definitions (DTDs) or schemas are required for validation, the Xml Resolver property is used.The following tables outline the values for the Validation Type property.