Shiraz Bhaiji
Shiraz Bhaiji

Reputation: 65481

XmlSchema.Read does not load xsd correctly

I am tring to load an xsd file using XmlSchema.Read. It runs without error, and I can see that it reads the namespace from the file, but I cannot read any other data from the xsd file.

Here is my code:

public XmlSchema GetXSDFileAsXMLSchema()
    {
        FileStream fs = new FileStream(path, FileMode.Open);
        XmlSchema schema = XmlSchema.Read(fs, new ValidationEventHandler(ValidationCallBack));
        return schema;
    }

    private void ValidationCallBack(object sender, ValidationEventArgs args)
    {
        return; 
    }  

Anybody know why the count of elements is 0?

Upvotes: 2

Views: 7760

Answers (1)

fejesjoco
fejesjoco

Reputation: 11903

MSDN says that elements only gets filled after you call Compile(). Before that, you can use the raw elements of the schema, like Items.

Upvotes: 6

Related Questions