How to parse XSD file using c#

♀尐吖头ヾ 提交于 2021-02-10 13:49:09

问题


I want to read XSD File. But unable to find a proper way to parse XSD file.

<xsd:group name="group_name">
    <xsd:annotation>
        <xsd:documentation>Some text is here</xsd:documentation>
    </xsd:annotation>
    <xsd:sequence>
        <xsd:element minOccurs="0" name="Element_1" type="string">
            <xsd:annotation>
                <xsd:documentation>Some text is here</xsd:documentation>
            </xsd:annotation>
        </xsd:element>
        <xsd:element minOccurs="0" name="Element_2" type="string">
            <xsd:annotation>
                <xsd:documentation>Some text is here</xsd:documentation>
            </xsd:annotation>
        </xsd:element>
    </xsd:sequence>
</xsd:group>

I want to read each group in my file, a sequence in that group and element in that sequence. And also need to read annotation of each group, I can element.

How can I do that?


回答1:


XSD File are XML file, so you can read ot using XML parser such as LINQ which is a query to read data from data source, the link bellow is a good source about it: https://msdn.microsoft.com/en-us/library/bb397933.aspx So, the first step is to load the xml file then read it by LINQ query



来源:https://stackoverflow.com/questions/34855024/how-to-parse-xsd-file-using-c-sharp

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!