I've an xml file as follows:
<ProductGroup>
<Product id="4601A">
<name>Roses</name>
<section>Floral</section>
<price>46</price>
<PopupImages>
<PopupImage>img1.jpg</PopupImage>
<PopupImage>img2.jpg</PopupImage>
</PopupImages>
<ImageThumbs>
<thumb>img1-thm.jpg</thumb>
<thumb>img2-thm.jpg</thumb>
</ImageThumbs>
</Product>
</ProductGroup>
In production the ProductGroup node might contain many Product nodes. For this I kind of want to build a list of an anonymous object that has the following properties:
name
section
image
thumb
I am able to get a list of Product elements using XDocument.
Dim doc As XDocument = XDocument.Load("ProductsGroups.xml")
Dim lstProducts = from x In doc Where CType(c.Element("price"), Integer) < 54
From here what do I do?
Update:
Let me explain this better. I am not sure if I have communicated this properly.
Taking the above xml example itself. The above code I've written returns all product elements with the specified "where" condition. Now for each XmlElement returned (product) I've to create n-number of anonymous objects. The number n depends on how many children are there for the PopupImages and ImageThumbs nodes. In my case however, the number will be the same. Hence coming back to the above example, I'd get two anonymous objects:
Anonymous1 Anonymous2
---------- ----------
name Roses Roses
section Floral Floral
image img1.jpg img2.jpg
thumb img1-thm.jpg img2-thm.jpg