title: Parsing XML with VB.net
body: <p>I'm trying to make sense of a big data dump of XML that I need to write to a database using some VB.net code. I'm looking for some help getting started with the parsing code, specifically how to access the attribute values.</p>
  
  <pre><code>                  &lt;Product ID="523233" UserTypeID="Property" ParentID="523232"&gt;
                  &lt;Name&gt;My Property Name&lt;/Name&gt;                     
                  &lt;AssetCrossReference AssetID="173501" Type=" Non Print old"&gt;
                    &lt;/AssetCrossReference&gt;
                    &lt;AssetCrossReference AssetID="554740" Type=" Non Print old"&gt;
                    &lt;/AssetCrossReference&gt;
                    &lt;AssetCrossReference AssetID="566495" Type=" Non Print old"&gt;
                    &lt;/AssetCrossReference&gt;
                    &lt;AssetCrossReference AssetID="553014" Type="Non Print"&gt;
                    &lt;/AssetCrossReference&gt;
                    &lt;AssetCrossReference AssetID="553015" Type="Non Print"&gt;
                    &lt;/AssetCrossReference&gt;
                    &lt;AssetCrossReference AssetID="553016" Type="Non Print"&gt;
                    &lt;/AssetCrossReference&gt;
                    &lt;AssetCrossReference AssetID="553017" Type="Non Print"&gt;
                    &lt;/AssetCrossReference&gt;
                    &lt;AssetCrossReference AssetID="553018" Type="Non Print"&gt;
                    &lt;/AssetCrossReference&gt;
  
                  &lt;Values&gt;
                    &lt;Value AttributeID="5115"&gt;Section of main pool&lt;/Value&gt;
                    &lt;Value AttributeID="5137"&gt;114 apartments, four floors, no lifts&lt;/Value&gt;
                    &lt;Value AttributeID="5170"&gt;Property location&lt;/Value&gt;
                    &lt;Value AttributeID="5164"&gt;2 key&lt;/Value&gt;
                    &lt;Value AttributeID="5134"&gt;A comfortable property, the apartment is set on a pine-covered hillside - a scenic and peaceful location.&lt;/Value&gt;
                    &lt;Value AttributeID="5200"&gt;PROPERTY_ID&lt;/Value&gt;
                    &lt;Value AttributeID="5148"&gt;facilities include X,Y,Z&lt;/Value&gt;
                    &lt;Value AttributeID="5067"&gt;Self Catering. &lt;/Value&gt;
                    &lt;Value AttributeID="5221"&gt;Frequent organised daytime activities&lt;/Value&gt;
                  &lt;/Values&gt;
                &lt;/Product&gt;
              &lt;/Product&gt;
  </code></pre>
  
  <p>Basically I want to find a property within the xml file that has a certain property ID. So it would be something like the code listed below which is my interpretation of what it should be. The code doesn't work, so I'm going wrong somewhere with it.</p>
  
  <p>This is the relevant line that I need to be able to access: </p>
  
  <pre><code>&lt;Value AttributeID="5200"&gt;PROPERTY_ID&lt;/Value&gt;
  
  
  Dim productsXML As XElement = XElement.Load("C:\myFile.xml")
  
  Dim foundNode As XElement
  
  Dim query = From p In productsXML.Elements("Product").Descendants("Values") Where p.Attributes("attribute").ToString = "PROPERTY_ID"
  
  foundNode = query.FirstOrDefault()
  </code></pre>