【问题标题】:How to generate XSD file from a tree text in windows forms using C#如何使用 C# 从 Windows 窗体中的树文本生成 XSD 文件
【发布时间】:2013-02-13 07:52:31
【问题描述】:

我需要从树视图生成 XSD 文件。也就是说,树节点文本应该是 XSD 文件的元素。 例如。想象一下我有以下树。

章节

    Heading
       Section
           Paragraph
               Sentance

在按钮上单击我的输出应该是

<xs:element name="Chapter" type="xs:string">
    <xs:element name="Heading" type="xs:string">
      <xs:element name="Session" type="xs:string">
        <xs:element name="Para" type="xs:string">         
        </xs:element>      
      </xs:element>    
    </xs:element>  
  </xs:element>

我有以下代码,但它只返回第一行。谁能帮忙?

int i = 0; 字符串 XSD = string.Empty;

    private void button1_Click(object sender, EventArgs e)
    {
       XSD=XSDString(XSD,tvMain.Nodes[0]);
       textBox1.Text = XSD.ToString(); 
    }

    private string XSDString(string XSD, TreeNode tnode)
    {
        for (i = 0; i < tnode.Nodes.Count; i++)
        {
            XSD = XSD + "<xs:element name=" + tnode.Nodes[i].Text + " "+ "type=" + "xs:string" + ">";
            XSDString(XSD, tnode.Nodes[i]);
            XSD = XSD + "</xs:element>";
        }
        return XSD;
    }

【问题讨论】:

    标签: xml winforms xsd treeview


    【解决方案1】:

    我得到了答案..我只需要 XSD 来保持价值..

    XSD = XSDString(XSD, tnode.Nodes[i]);

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-04-08
      • 1970-01-01
      • 1970-01-01
      • 2010-10-07
      • 2021-01-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多