XDocument 的内容是下面的 XML。
我想要一个 List(),请参阅此消息的末尾。
<myXml>
<myDatas code="01">
<myVar name="myvar" value="A" />
<myData name="A" value="A1" />
<myData name="B" value="B1" />
</myDatas>
<myDatas code="02">
<myVar name="myvar" value="B" />
<myData name="A" value="A2" />
<myData name="D" value="D2" />
</myDatas>
</myXml>
public class MyData
{
public string MainCode { get; set; }
public string Code { get; set; }
public string Value { get; set; }
}
我想要一个 List() 这个内容应该是这样的:
new MyData { MainCode = "01"; Code = "A"; Value = "A1" };
new MyData { MainCode = "01"; Code = "B"; Value = "B1" };
new MyData { MainCode = "02"; Code = "A"; Value = "A2" };
new MyData { MainCode = "02"; Code = "D"; Value = "D2" };