Quantcast
Channel: .NET Framework Class Libraries forum
Viewing all articles
Browse latest Browse all 8156

Linq confusion - Nube question

$
0
0

Hi

I'm just starting to look at LINQ to XML to access information from a web service. I have the code below:

var z = from c in xdoc.Descendants("content")
where c.Value == "Asbestos" && c.ElementsAfterSelf("item").Count<XElement>() > 0
select new
{
     xnode = c.ElementsAfterSelf("item").Descendants("content").Elements("name")
};

When I run the code, and expand the results views for z, I get the following:

<name class="Document" icon="Images/Icons/Document.png" link="Asbestos">http://site.com?docID=1">Asbestos document A 21/01/2014</name>
<name class="Document" icon="Images/Icons/Document.png" link="Asbestos">http://site.com?docID=2Asbestos">">Asbestos Image 1 21/01/2014</name>
<name class="Document" icon="Images/Icons/Document.png" link="Asbestos">http://site.com?docID=3Asbestos">">Asbestos document B 21/01/2014</name>

This does contain the data I want, but I want to have it as a data table so I can bind it to a gridview or similar as below:

Type                  link                                          filename

Document          http://site.com?docID=1           Asbestos document A 21/01/2014

Document          http://site.com?docID=2Asbestos">           Image 1 21/01/2014

Document          http://site.com?docID=3           Asbestos document B 21/01/2014


Any help appreciated.

Thanks


Viewing all articles
Browse latest Browse all 8156

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>