我有一个看起来像这样的 xml 文件:
<SalesReps>
<SalesRep>
<repname> Bob</repname>
<repid>100</repid>
<customers>
<customer>
<custname>ABC Company</custname>
<custno>51233</custno>
</customer>
<customer>
<custname>XYZ Inc.</custname>
<custno>29943</custno>
</customer>
</customers>
</SalesRep>
<SalesRep>
<repname>Sue</repname>
<repid>43</repid>
<customers>
<customer>
<custname>Petes Tire Co</custname>
<custno>49999</custno>
</customer>
<customer>
<custname>Suzy's Sewing</custname>
<custno>81234</custno>
</customer>
</customers>
</SalesRep>
</SalesReps>
我正在尝试使用以下代码阅读它:
Dim salesreps = From reps In xe.Descendants("SalesReps") Select reps
Dim el = (From rep In salesreps _
Select New With {.repname = rep.<repname>, _
.repid = rep.<repid>,
.customers = (From custs In rep.<Customers> _
Select New With { _
.customer = ( _
From cust In custs.<customer> _
Select New With {
.custname = cust.<custname>.Value, _
.custno = cust.<custno>.Value} _
)} _
) _
} _
)
我可以得到 repname 和 repid,但没有得到带有 custname 和 custno 的客户列表。我究竟做错了什么?
谢谢