Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/338.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# 如何将xsi:noNamespaceSchemaLocation添加到序列化程序_C#_Xml_Xsd - Fatal编程技术网

C# 如何将xsi:noNamespaceSchemaLocation添加到序列化程序

C# 如何将xsi:noNamespaceSchemaLocation添加到序列化程序,c#,xml,xsd,C#,Xml,Xsd,我构建了一个需要根据xsd文件进行验证的XML文档。因此,我需要在xml的根元素中引用xsd文件。到目前为止,我使用的是C代码: 生成的Xml如下所示开始: 但我需要这个: 我在这里遇到了“CreateAttribute”:但我无法将其与序列化程序结合起来。谢谢大家! 我在这里找到了解决方案: 我在课堂上添加了以下内容: [XmlAttribute("noNamespaceSchemaLocation", Namespace = XmlSchema.InstanceNamespace)

我构建了一个需要根据xsd文件进行验证的XML文档。因此,我需要在xml的根元素中引用xsd文件。到目前为止,我使用的是C代码:

生成的Xml如下所示开始:


但我需要这个:



我在这里遇到了“CreateAttribute”:但我无法将其与序列化程序结合起来。谢谢大家!

我在这里找到了解决方案:

我在课堂上添加了以下内容:

[XmlAttribute("noNamespaceSchemaLocation", Namespace = XmlSchema.InstanceNamespace)]
    public string attr = "utils/theveryimportant.xsd";

它是有效的。

我在这里找到了解决方案:

我在课堂上添加了以下内容:

[XmlAttribute("noNamespaceSchemaLocation", Namespace = XmlSchema.InstanceNamespace)]
    public string attr = "utils/theveryimportant.xsd";
它是有效的。

查看哪个显示了如何同时添加
xsi:noNamespaceSchemaLocation
xsi:schemaLocation
查看哪个显示了如何同时添加
xsi:noNamespaceSchemaLocation
xsi:schemaLocation