0

我有一个具有以下结构的 xml 文件,

<TestClass>
  <TestChildClass>
    <TestName Name="sample">
      <Table Name="table1" IdentityColumnName="RollNo" IntColumn="Mark" CharColumn="Name" >
        <Table Name="table2" IdentityColumnName="RollNo" IntColumn="SubjectCode" CharColumn="Subject" ReferenceColumn ="RollNo" >
            <Table Name="table3" IdentityColumnName="RollNo" IntColumn="Average" CharColumn="Subject" ReferenceColumn ="SubjectCode"/>          
         </Table>

        <Table Name="table4" IdentityColumnName="RollNo" IntColumn="Rank" CharColumn="Name" />
      </Table >
    </TestName >    
  </TestChildClass>
  </TestClass>

我使用 XSD.EXE 为上述 xml 创建了一个类。但问题是,当我尝试为名为 TestClass.cs 的新类创建对象时,它会抛出错误,例如“同一个表‘表’不能是两个嵌套关系中的子表。” 如何解决这个问题?

4

1 回答 1

1

Your XML is not valid, you need to remove the lines and make sure to close the node for Table1

<TestClass>
  <TestChildClass>
    <TestName Name="sample">
      <Table Name="table1" IdentityColumnName="RollNo" IntColumn="Mark" CharColumn="Name" >
        <Table Name="table2" IdentityColumnName="RollNo" IntColumn="SubjectCode" CharColumn="Subject" ReferenceColumn ="RollNo" >
            <Table Name="table3" IdentityColumnName="RollNo" IntColumn="Average" CharColumn="Subject" ReferenceColumn ="SubjectCode"/>          
         </Table>
        <Table Name="table4" IdentityColumnName="RollNo" IntColumn="Rank" CharColumn="Name" />
      </Table >
    </TestName >    
  </TestChildClass>
</TestClass>
于 2012-10-09T13:02:00.803 回答