Note that there are some explanatory texts on larger screens.

plurals
  1. POLINQ To XML Syntax for XML Element with Attributes
    primarykey
    data
    text
    <p>I'm a bit of a LINQ newbie and I was having some trouble with the following. I'm trying to perform a query using LINQ on an XML file and store the results in a list of DataClass objects that match the XML.</p> <p>I've got an XML file that is defined like this:</p> <pre><code>&lt;NewDataSet&gt; &lt;NewDataTable&gt; &lt;Field&gt;Accepted ASNs&lt;/Field&gt; &lt;Val&gt;59&lt;/Val&gt; &lt;Order Number="1234" ShipDate="2009/05/21" /&gt; &lt;Order Number="2190" ShipDate="2009/05/22" /&gt; &lt;Order Number="1809" ShipDate="2009/05/22" /&gt; &lt;/NewDataTable&gt; &lt;NewDataTable&gt; &lt;Field&gt;Rejected ASNs&lt;/Field&gt; &lt;Val&gt;8&lt;/Val&gt; &lt;Order Number="2901" ShipDate="2009/05/21" /&gt; &lt;Order Number="2810" ShipDate="2009/05/24" /&gt; &lt;Order Number="1419" ShipDate="2009/05/25" /&gt; &lt;/NewDataTable&gt; &lt;NewDataTable&gt; &lt;Field&gt;Missing ASNs&lt;/Field&gt; &lt;Val&gt;7&lt;/Val&gt; &lt;Order Number="2902" ShipDate="2009/05/19" /&gt; &lt;Order Number="2898" ShipDate="2009/05/20" /&gt; &lt;Order Number="1296" ShipDate="2009/05/22" /&gt; &lt;/NewDataTable&gt; &lt;/NewDataSet&gt; </code></pre> <p>I have created a Data class to support this XML format. What I would like to do is create a LINQ Query to grab these 3 records and store them into a List of my DataClass. </p> <p>In order to support multiple Order elements, I have my class defined with a generic list of "Order" structs... It looks like this:</p> <pre><code> Public Class ASNData Private _field As String Private _value As String Private _orders As List(Of Order) Public Property Field() As String Get Set End Property Public Property Value() As String Get Set End Property Public Property Orders() As List(Of Order) Get Set End Property Structure Order Private _number As String Private _date As Date Public Property Number() As String Get Set End Property Public Property ShippingDate() As Date Get Set End Property End Structure End Class </code></pre> <p>The biggest issue I'm having is figuring out how to grab the 3 order elements and store them into my list of Order structs. </p> <p>Can anyone point me in the right direction on this? </p> <p>Thank you.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload