Reuse the result of a query of an Xelement

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
I have a basic query that I want to use the resulting xml to different data in different parts and also query again (if selected) Do I have to query the data fully each time or can I just query the result at a later time?

<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; Public DataXml <span style="color:Blue; As XElement



<span style="color:Blue; Private <span style="color:Blue; Sub Form1_Load(<span style="color:Blue; ByVal sender <span style="color:Blue; As System.Object, <span style="color:Blue; ByVal e <span style="color:Blue; As System.EventArgs) <span style="color:Blue; Handles <span style="color:Blue; MyBase.Load

<span style="color:Blue; Dim song <span style="color:Blue; As XElement
song = XElement.Load(<span style="color:#A31515; "c:songs.xml")
<span style="color:Blue; Dim clist <span style="color:Blue; As IEnumerable(Of XElement) = _
<span style="color:Blue; From El <span style="color:Blue; In song.Elements, g <span style="color:Blue; In El.<Category>.Elements(<span style="color:#A31515; "Genre") _
<span style="color:Blue; Where g.Value.Contains(<span style="color:#A31515; "Pop") _
<span style="color:Blue; Select El

DataXml = clist.Elements()

<span style="color:Blue; End <span style="color:Blue; Sub
[/code]

Something like that and then...

<div style="color:Black;background-color:White; <pre>

<span style="color:Blue; Dim newQ <span style="color:Blue; As IEnumerable(Of XElement) = _
<span style="color:Blue; From El <span style="color:Blue; In DataXml.Elements, g <span style="color:Blue; In El.<Data>.Elements(<span style="color:#A31515; "Popular") _
<span style="color:Blue; Where g.Value.Contains(<span style="color:#A31515; "Yes") _
<span style="color:Blue; Select El


DataXml = newQ.Elements()
[/code]

and so on
Thank you for your help :)
Andy <hr class="sig Currently working on my first VB Project - A music Player - until i am old enough to take programing at school :) Please be kind as I am only learning and I learn best by dissecting something, rebuilding it and asking questions :)

View the full article
 
Back
Top