Xml validating reader example
Register the method Validation Error with the settings object's Validation Event Handler.
The Validation Error method is called if the document being read is found to be invalid or an error occurs (for example, the document cannot be found).
However, when the user selects the XML document catalog1.xml, validation fails for the book element in the lines containing more than one title element.
The Xml Document class validates the XML data as it is loaded into the DOM when a validating Xml Reader is passed to the Load method of the Xml Document class. Create("contoso Books.xml", settings) ' The Xml Document validates the XML document contained ' in the Xml Reader as it is loaded into the DOM.
After successful validation, schema defaults are applied, text values are converted to atomic values as necessary, and type information is associated with validated information items. Dim document As Xml Document = New Xml Document() document.
As a result, typed XML data replaces previously untyped XML data. Load(reader) ' Make an invalid change to the first and last ' price elements in the XML document, and write ' the Xml Schema Info values assigned to the price ' element during load validation to the console.
To create an XML schema-validating Xml Reader, follow these steps. Dim manager As Xml Namespace Manager = New Xml Namespace Manager(document. Add Namespace("bk", " Dim price Node As Xml Node = document.