Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/287.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中的根元素_C# - Fatal编程技术网

C# 访问XMLSchema中的根元素

C# 访问XMLSchema中的根元素,c#,C#,我将XMLString映射到XMLSchema,代码如下(我将Schema与任何元素一起使用): 请告诉我如何解决此问题。从字符串中删除 这里是更新代码 settings.Schemas.Add(null, XmlReader.Create( new StringReader(@"<xs:schema xmlns:xs=""http://www.w3.org/2001/XMLSchema""> <xs:eleme


我将XMLString映射到XMLSchema,代码如下(我将Schema与任何元素一起使用):

请告诉我如何解决此问题。

从字符串中删除

这里是更新代码

    settings.Schemas.Add(null, XmlReader.Create(
    new StringReader(@"<xs:schema  xmlns:xs=""http://www.w3.org/2001/XMLSchema"">
                        <xs:element name=""root"" type=""RootElementType""/>
                        <xs:complexType name=""RootElementType"">
                        <xs:sequence>
                         <xs:any />
                        </xs:sequence>
                       </xs:complexType>
                 </xs:schema>")));
settings.Schemas.Add(null,XmlReader.Create(
新StringReader(@)
")));

谢谢:但它引发了一个错误:类型属性不能与simpleType或complexType一起出现。
settings.Schemas.Add(null, XmlReader.Create(new StringReader(@"<xs:schema  xmlns:xs=""http://www.w3.org/2001/XMLSchema"">
                                                            <xs:element name=""root"" type=""RootElementType""/>
                                                            <xs:complexType name=""RootElementType"">
                                                            <xs:sequence>
                                                             <xs:any />
                                                            </xs:sequence>
                                                           </xs:complexType>
                                                        </xs:element>
                                                     </xs:schema>")));
The 'xs:schema' start tag on line 1 position 2 does not match the end tag of 'xs:element'. Line 8, position 63.
    settings.Schemas.Add(null, XmlReader.Create(
    new StringReader(@"<xs:schema  xmlns:xs=""http://www.w3.org/2001/XMLSchema"">
                        <xs:element name=""root"" type=""RootElementType""/>
                        <xs:complexType name=""RootElementType"">
                        <xs:sequence>
                         <xs:any />
                        </xs:sequence>
                       </xs:complexType>
                 </xs:schema>")));