• <tfoot id='fCBhp'></tfoot>

    1. <small id='fCBhp'></small><noframes id='fCBhp'>

      <i id='fCBhp'><tr id='fCBhp'><dt id='fCBhp'><q id='fCBhp'><span id='fCBhp'><b id='fCBhp'><form id='fCBhp'><ins id='fCBhp'></ins><ul id='fCBhp'></ul><sub id='fCBhp'></sub></form><legend id='fCBhp'></legend><bdo id='fCBhp'><pre id='fCBhp'><center id='fCBhp'></center></pre></bdo></b><th id='fCBhp'></th></span></q></dt></tr></i><div id='fCBhp'><tfoot id='fCBhp'></tfoot><dl id='fCBhp'><fieldset id='fCBhp'></fieldset></dl></div>
      • <bdo id='fCBhp'></bdo><ul id='fCBhp'></ul>

        <legend id='fCBhp'><style id='fCBhp'><dir id='fCBhp'><q id='fCBhp'></q></dir></style></legend>
      1. C# - 解析 XSD 架构 - 将所有元素获取到组合框

        时间:2023-06-02
        • <bdo id='3SYOA'></bdo><ul id='3SYOA'></ul>
            <tbody id='3SYOA'></tbody>
          • <i id='3SYOA'><tr id='3SYOA'><dt id='3SYOA'><q id='3SYOA'><span id='3SYOA'><b id='3SYOA'><form id='3SYOA'><ins id='3SYOA'></ins><ul id='3SYOA'></ul><sub id='3SYOA'></sub></form><legend id='3SYOA'></legend><bdo id='3SYOA'><pre id='3SYOA'><center id='3SYOA'></center></pre></bdo></b><th id='3SYOA'></th></span></q></dt></tr></i><div id='3SYOA'><tfoot id='3SYOA'></tfoot><dl id='3SYOA'><fieldset id='3SYOA'></fieldset></dl></div>
          • <legend id='3SYOA'><style id='3SYOA'><dir id='3SYOA'><q id='3SYOA'></q></dir></style></legend>
            <tfoot id='3SYOA'></tfoot>

                  <small id='3SYOA'></small><noframes id='3SYOA'>

                  本文介绍了C# - 解析 XSD 架构 - 将所有元素获取到组合框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我有 XSD 架构文件,我需要用架构文件中的元素填充我的组合框...

                  I have XSD Schema file and i need to fill my combobox with the elements from the schema file...

                  <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
                     <xs:element name="auto">
                        <xs:complexType>
                           <xs:sequence>
                              <!-- Znacka -->
                              <xs:element name="znacka" type="xs:string"/>
                              <!-- pocetOsob -->
                              <xs:element name="pocetOsob" type="xs:int"/>
                              <!-- maxRychlost -->
                              <xs:element name="maxRychlost">
                                 <xs:complexType>
                                    <xs:simpleContent>
                                       <xs:extension base="xs:decimal">
                                          <xs:attribute name="jednotka" type="xs:string"/>
                                       </xs:extension>
                                    </xs:simpleContent>
                                 </xs:complexType>
                              </xs:element>
                              <!-- Motor -->
                              <xs:element name="motor">
                                 <xs:complexType>
                                    <xs:sequence>
                                       <xs:element name="vykon">
                                          <xs:complexType>
                                             <xs:simpleContent>
                                                <xs:extension base="xs:decimal">
                                                   <xs:attribute name="jednotka" type="xs:string"/>
                                                </xs:extension>
                                             </xs:simpleContent>
                                          </xs:complexType>
                                       </xs:element>
                                    </xs:sequence>
                                    <xs:attribute name="vyrobni_cislo" type="xs:string"/>
                                 </xs:complexType>
                              </xs:element>
                           </xs:sequence>
                        </xs:complexType>
                     </xs:element>
                  </xs:schema> 
                  

                  有人知道怎么做吗?通过xpath?我有一半工作的代码...我收到一条带有元素 auto 的消息.

                  Anyone had idea how to do it? Through xpath? I have a half working code... I got a message with element auto.

                  String path = openSchema.FileName;
                  XmlTextReader xsd_file = new XmlTextReader(path);
                  XmlSchema schema = new XmlSchema();
                  schema = XmlSchema.Read(xsd_file, null);
                  
                  MessageBox.Show(schema.Items.Count.ToString());
                  
                  foreach (XmlSchemaElement element in schema.Items)
                  {
                      elements.Items.Add(element.Name);
                      MessageBox.Show(element.Name);
                  }
                  

                  非常感谢!

                  推荐答案

                  string xml = <your xml>;
                  var xs = XNamespace.Get("http://www.w3.org/2001/XMLSchema");
                  var doc = XDocument.Parse(xml);
                  // if you have a file: var doc = XDocument.Load(<path to xml file>)
                  foreach(var element in doc.Descendants(xs + "element"))
                  {
                      Console.WriteLine(element.Attribute("name").Value);
                  }
                  // outputs: 
                  // auto
                  // znacka
                  // pocetOsob
                  // maxRychlost
                  // motor
                  // vykon
                  

                  这篇关于C# - 解析 XSD 架构 - 将所有元素获取到组合框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:在构建期间自动化 xsd.exe 下一篇:xsd.exe 将类生成为单独的文件?

                  相关文章

                  最新文章

                      <small id='DggD7'></small><noframes id='DggD7'>

                      <legend id='DggD7'><style id='DggD7'><dir id='DggD7'><q id='DggD7'></q></dir></style></legend><tfoot id='DggD7'></tfoot>
                        <bdo id='DggD7'></bdo><ul id='DggD7'></ul>
                    1. <i id='DggD7'><tr id='DggD7'><dt id='DggD7'><q id='DggD7'><span id='DggD7'><b id='DggD7'><form id='DggD7'><ins id='DggD7'></ins><ul id='DggD7'></ul><sub id='DggD7'></sub></form><legend id='DggD7'></legend><bdo id='DggD7'><pre id='DggD7'><center id='DggD7'></center></pre></bdo></b><th id='DggD7'></th></span></q></dt></tr></i><div id='DggD7'><tfoot id='DggD7'></tfoot><dl id='DggD7'><fieldset id='DggD7'></fieldset></dl></div>