tags:

views:

15

answers:

2

Hi, i have the following schema loaded into an xmlSchema :

...
<xs:import schemaLocation="\_1.xsd" namespace="http://tempuri.org/" />
...

i want to retrive the string "_1.xsd"

how do i reach the schemaLocation value from XmlSchema API ? will schemaSet work better ?

Thanks

A: 
using System.Xml.Schema;
using System.IO;
using System.Reflection;

This should work, might throw some errors, as I didnt compile it in an IDE as im not on a Dev machine atm.

string xsd = "example.xsd";

FileStream fs;
XmlSchema schema;

fs = new FileStream(xsd, FileMode.Open);
schema = XmlSchema.Read(fs, new ValidationEventHandler(ShowCompileError));

foreach (XmlSchemaObject externalSchema in schema.Includes)
{
    string schemaLoc = (XmlSchemaExternal)externalSchema.SchemaLocation.ToString();
}
kyndigs
A: 

i finally used this :

schema.Includes[0] as XmlSchemaImport;
var wsdlId = schemaImport.SchemaLocation;
Gady