My experiences with XmlReader class have been kind of mixed right now. I do want to clarify some of the basic doubts which I have with validating the Xml data using XmlReader class.
- I know one can use the XmlReaderSettings class to set up some settings as to whether to turn on/off validation, setting the validation type, etc.. and create an XmlReader with the xml file and the settings object.
- I also know that you need to add all your schema files used for validation into the XmlSchemaSet class unless the schema is present inside the Xml document (inline schema)
There is a property in XmlSchemaValidationFlags class called as XmlSchemaValidationFlags.ProcessSchemaLocation
So, if I do have the location of the xsd file specified in the xml file given below, do I need to add the xsd file to the XmlSchemaSet class? I have kept the xsd file in the same dir as of the xml file.
<?xml version="1.0" encoding="utf-8"?>
<value_tables xmlns="urn:values-schema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:values-schema values.xsd"
>
<table name="Calibrated">
<value num="0">No</value>
<value num="1">Yes</value>
</table>
</value_tables>
Q2. Also, is it possible to retrieve the name of this file from the xml document rather than hardcoding it?