【问题标题】:How to parse XSD file using c#如何使用 C# 解析 XSD 文件
【发布时间】:2017-02-08 16:01:43
【问题描述】:

我想读取 XSD 文件。但无法找到解析 XSD 文件的正确方法。

<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>

我想读取文件中的每个组、该组中的序列和该序列中的元素。并且还需要阅读每个组的注释,我可以元素。

我该怎么做?

【问题讨论】:

    标签: c# xsd


    【解决方案1】:

    XSD 文件是 XML 文件,因此您可以使用 XML 解析器(例如 LINQ)读取 ot,它是从数据源读取数据的查询,下面的链接是一个很好的来源: https://msdn.microsoft.com/en-us/library/bb397933.aspx 因此,第一步是加载 xml 文件,然后通过 LINQ 查询读取它

    【讨论】:

    • 或者他可以生成一个对应XML schema的类并反序列化
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-30
    • 2010-10-25
    • 1970-01-01
    • 2012-05-24
    相关资源
    最近更新 更多