使用Linq的XML到字典 - 没有获得Child值

时间:2017-05-11 15:31:53

标签: xml vb.net linq

这是我的测试XML

<Customer>
  <CustomerId>123456</CustomerId>
  <CustomerName>ERA01SB17 0101</CustomerName>
 <Address>
    <AddressLine>9955 Rough Rd</AddressLine>
    <City>ST LOUIS</City>
    <County>KING</County>
    <StateOrProvince>MO</StateOrProvince>
    <Country>US</Country>
    <PostalCode>12345</PostalCode>
 </Address>
 <Contact>
 <PersonName>
    <GivenName>Jim Johnson</GivenName>
    <FamilyName/>
</PersonName>
</Contact>
</Customer

这是我在VB.NET中的代码

Dim dictionaryOut = doc.Root.Elements().ToDictionary(Function(e) e.Name.LocalName, Function(e) e.Value)

输出将地址子节点连接在一起

Address, 9955 Rough RdST LOUISKINGMOUS12345

如何让所有拥有Field名称和值的孩子?

谢谢

0 个答案:

没有答案