1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Help me change this function please.

Discussion in 'C#' started by rhaazy, Jul 10, 2007.

  1. rhaazy

    rhaazy New Member

    Joined:
    Jul 6, 2007
    Messages:
    28
    Likes Received:
    0
    Trophy Points:
    0
    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();
                }
    
     

Share This Page