开发者

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();
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜