finding schemaLocation in c# XmlSchema
i have the following schema loaded into an xmlSchema :
...
<xs:im开发者_如何学Pythonport 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
i finally used this :
schema.Includes[0] as XmlSchemaImport;
var wsdlId = schemaImport.SchemaLocation;
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();
}
精彩评论