Xml 如何使用C从windows窗体中的树文本生成XSD文件#

Xml 如何使用C从windows窗体中的树文本生成XSD文件#,xml,winforms,xsd,treeview,Xml,Winforms,Xsd,Treeview,我需要从树视图生成XSD文件。也就是说,树节点文本应该是XSD文件的元素。 例如想象我有下面的树 章 Heading Section Paragraph Sentance 在按钮上单击“我的输出”应为 <xs:element name="Chapter" type="xs:string"> <xs:element name="Heading" type="xs:string">

我需要从树视图生成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; string 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;
    }
private void按钮1\u单击(对象发送者,事件参数e)
{
XSD=XSDString(XSD,tvMain.Nodes[0]);
textBox1.Text=XSD.ToString();
}
私有字符串XSDString(字符串XSD,TreeNode tnode)
{
对于(i=0;i
我得到了答案。。我只需要XSD来保存值


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

我得到了答案。。我只需要XSD来保存值

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