My XML has multiple elements but when I try to parse them using LINQ, I just get one element. Something is wrong with my select statement, but I'm having a devil of a time understanding what is wrong. The Result should be a dictionary populated with the InvoiceUid and InvoiceNumber for all the (2) invoiceListItems
Here is my XML:
<?xml version="1.0" encoding="utf-8"?>
<invoiceListResponse>
<invoiceList>
<invoiceListItem>
<invoiceUid>39165890</invoiceUid>
<invoiceDate>2013-12-26</invoiceDate>
<invoiceNumber>W10001888</invoiceNumber>
<contactUid>8363070</contactUid>
</invoiceListItem>
<invoiceListItem>
<invoiceUid>39149309</invoiceUid>
<invoiceDate>2013-12-24</invoiceDate>
<invoiceNumber>W100</invoiceNumber>
<contactUid>8363070</contactUid>
</invoiceListItem>
</invoiceList>
</invoiceListResponse>
and the meat of my code:
Dim list As XmlDocument = proxy.Find(queries)
Dim InvoiceList = XDocument.Parse(list.InnerXml)
' get all <InvoiceListItem> elements from the xdocumetn
Dim InvoiceListItems = From invoiceListItem In InvoiceList...<invoiceList>
Select invoiceListItem
'go through each InvoiceListItem in InvoiceListItems
For Each InvoiceListItem In InvoiceListItems
Console.WriteLine("Uid is {0} and Invoice Number is {1}", InvoiceListItem...<invoiceUid>.Value, InvoiceListItem...<invoiceNumber>.Value)
returnInvoiceList.Add(InvoiceListItem...<invoiceNumber>.Value, CType(InvoiceListItem...<invoiceUid>.Value, Integer))
Next
Return returnInvoiceList