I have a function that accepts two strings (file paths) as inputs. What I need change this function so that it can accept datasets, or something I can pass in memory.
Code:
public void ReadAndValidate(string path2XMLFile, string path2XSDFile)
{
using (FileStream fs = File.Open(path2XMLFile, FileMode.Open, FileAccess.Read))
{
//GS - Create an xml document to hold our xml
XmlDocument xdoc = new XmlDocument();
//GS - Create a reader settings, add the schema, set for
//schema validation and add a validation event handler
XmlReaderSettings settings = new XmlReaderSettings();
settings.Schemas.Add(null, path2XSDFile);
settings.ValidationType = ValidationType.Schema;
settings.ValidationEventHandler +=
new ValidationEventHandler(settings_ValidationEventHandler);
//GS - Load and validate the xml
XmlReader reader = XmlReader.Create(fs, settings);
xdoc.Load(reader);
//GS - Close the file stream when we’re done
fs.Close();
}