在XSD文件中提取自定义属性

时间:2014-11-20 16:18:23

标签: c# xml xsd schema

我能够使用System.Xml.Schema类获取所有节点,但我无法查询 b:fieldInfo 节点并使用任何标准xml方法提取属性。我不想把它解析为字符串。

 <xs:complexType>
      <xs:sequence>
        <xs:element name="Line1">
          <xs:complexType>
            <xs:sequence>
              <xs:annotation>
                <xs:appinfo>
                  <groupInfo sequence_number="0"/>
                </xs:appinfo>
              </xs:annotation>
              <xs:element name="Start" type="xs:string">
                <xs:annotation>
                  <xs:appinfo>
                    <b:fieldInfo justification="left" pos_offset="0" pos_length="15" sequence_number="1" />

1 个答案:

答案 0 :(得分:0)

使用XDocument

非常容易
var snip = XDocument.Parse(feildInfo);
var value = snip.Root.Attribute("justification").Value;
相关问题