tags:

views:

92

answers:

2

I am trying to get the value of <getthis> but can't seem to get just the string value. I think this is quite simple but I can't seem to get it. I am trying to do it with LINQ

XML

<?xml version="1.0" encoding="utf-8"?>
<root>
    <item>
        <name></name>
        <title></title>
    </item>
    <info>
        <getthis>value here</getthis>
        <something>another value</something>
    </info>
</upload>

I used

var link = from links in doc.Descendants("getthis")
           select links;

but I want just the value. How do I do it?

+4  A: 
var link = from links in doc.Descendants("getthis")
           select links.Value;
Darin Dimitrov
A: 

To be sure to get the getthis under info I would use the following:

var result = from info in xd.Descendants("info")
             from getthis in xd.Descendants("getthis")
             select getthis.Value;

If that's not important Darin's answer is correct.

mastoj