我有以下xml:
<state>
<groups>
<group id='1' name='Basic Search Options'>
<control name='Building' label='In' display='true' configurable='false'/>
<control name='SearchType' label='For' display='true' configurable='false'/>
<control id='1' default='C' name='Search By' label='By'>
<option searchtype='C' searchmode='Cnumber' value='CNumber' label='C Number' display='true'/>
<option searchtype='C' searchmode='crossrefnumber' value='CNumber1' label='Cross Reference Number' display='true'/>
<option searchtype='P' searchmode='' value='CaseNumber' label='P Name' display='true'/>
<option searchtype='P' searchmode='' value='CaseNumber' label='A Name' display='false'/>
</control>
</group>
<group id='2' name='Advanced Search Options'>
<control name='Ctatus' label='C Status' display='true'/>
<control name='DateFiled' label='Date Filed' display='true'/>
</group>
</groups>
我如何将其反序列化为以下对象?我不希望我的 xml 有以下标签“ArrayofGroup”,而是 xml 应该有上面提到的自定义标签。
public class GroupOfControls
{
public int instanceId { get; set; }
public int GroupId { get; set; }
public string Name { get; set; }
public List<SearchControl> Group { get; set; }
}
public class SearchControl
{
public string Name { get; set; }
public string Label { get; set; }
public bool Display { get; set; }
public string Default { get; set; }
public List<SearchOption> SearchOptions { get; set; }
}
public class SearchOption
{
public string Value { get; set; }
public string Label { get; set; }
public bool Display { get; set; }
public string SearchMode { get; set; }
public string SearchType { get; set; }
}
}