Xmlvalidatingreader is obsolete
Unless these schemas were explicitly added to the schema collection, they will not be accessible using any of the collection methods or properties.For example, if the collection contains the schema file a.xsd, which contains a reference to the schema file b.xsd, you must add to the schema collection before you can access it using any of the collection methods or properties.For example, the reported node type may be different than the actual node type of the current node. For more information, see the Remarks section of the Xml Reader reference page.I am trying to find an alternative to the following function, which is using the obsolete How can I adapt this code to work with XMLReader, which is what Visual Studio is suggesting as an alternative? 'VALIDATE XML Public Shared Function validate Xml(By Val xml String As String) As Xml Document xml Error Str = "" Dim str Reader As New String Reader(xml String) Dim xmlr As New Xml Text Reader(str Reader) Dim xmlvread As New Xml Validating Reader(xmlr) ' Set the validation event handler Add Handler xmlvread.Xml Validating Reader maps the namespace URI in the XML document to the schema that corresponds to that URI in the collection. Schema Namespace Validation Sample Class Sample Public Shared Sub Main() Dim tr As New Xml Text Reader("Head Count.xml") Dim vr As New Xml Validating Reader(tr) vr. This property must be set before the first call to Read. For more information, see the Remarks section of the Xml Reader reference page.
If the node is not a content node, the reader skips ahead to the next content node or end of file.
The reader does not add anything to the Xml Schema Collection.
If the Xml Schema Collection includes an XML schema (XSD) which contains include or import elements that reference other namespaces, the schemas for these other namespaces are loaded for validation purposes only.
property to guarantee that an XML instance document is validated against a schema.
The Severity property allows you to distinguish between validation errors (Severity is equal to Xml Severity Type.