Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在c#XmlSchema中查找schemaLocation_C#_Xsd - Fatal编程技术网

在c#XmlSchema中查找schemaLocation

在c#XmlSchema中查找schemaLocation,c#,xsd,C#,Xsd,我已将以下架构加载到xmlSchema中: ... <xs:import schemaLocation="\_1.xsd" namespace="http://tempuri.org/" /> ... 。。。 ... 我想检索字符串“_1.xsd” 如何从XMLSchemaAPI获得schemaLocation值? schemaSet会更好吗 谢谢 这应该可以工作,可能会抛出一些错误,因为我没有在IDE中编译它,因为我不是在开发机器atm上 string xsd = "examp

我已将以下架构加载到xmlSchema中:

...
<xs:import schemaLocation="\_1.xsd" namespace="http://tempuri.org/" />
...
。。。
...
我想检索字符串“_1.xsd”

如何从XMLSchemaAPI获得schemaLocation值? schemaSet会更好吗

谢谢

这应该可以工作,可能会抛出一些错误,因为我没有在IDE中编译它,因为我不是在开发机器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();
}
这应该可以工作,可能会抛出一些错误,因为我没有在IDE中编译它,因为我不是在开发机器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();
}
我最后用了这个:

schema.Includes[0] as XmlSchemaImport;
var wsdlId = schemaImport.SchemaLocation;
我最后用了这个:

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