Accepted answer

your code has several problems. first, the thing the compiler is complaining about is, as @mizardx mentioned, that you are using fo.element("value") as if it was a sequence. what you probably want is to write let e = fo.element("value") (or skip this part completely and directly write select fo.element("value").value).

another problem is that your xml is using a namespace, but you aren't. this means that you should create a xnamespace object and use it wherever you have element names.

also, the way your code is written, aircrafttype is a sequence of strings. i assume this is not what you wanted.

and seeing that you want to do the same thing for different values of fieldname, you probably want to make this into a method.

with all the problems mentioned above fixed, the code should look something like this:

static readonly xnamespace ns = xnamespace.get("urn:crystal-reports:schemas");

string getfieldvalue(xelement fs, string fieldname)
    return (from fo in fs.descendants(ns + "formattedreportobject")
            where fo.attribute("fieldname").value == fieldname
            let e = fo.element(ns + "value")
            select e.value).single();
var flts = (from fs in xdoc.descendants(ns + "formattedsection")
            select new flightschedule
                aircrafttype = getfieldvalue(fs, "{aircraft.type id}"),


fo.element("value") returns an xelement-object. what you want is probably fo.elements("value") (note the plural 's').

the error message was complaining that it didn't know how to iterate over the xelement object.

the reason you are not getting any results, is that the xml-file is using namespaces. to find elements outside the default namespace, you need to prefix the namespace before the node name.

i also noticed that you are not using the fos variable, so that loop is unnecessary. fs.decendants() is already giving you the correct result.

list<flightschedule> flts =
    (from fs in xdoc.descendants("{urn:crystal-reports:schemas}formattedsection")
     select new flightschedule
         aircrafttype =
             (from fo in fs.descendants("{urn:crystal-reports:schemas}formattedreportobject")
              where fo.attribute("fieldname").value == "{aircraft.type id}"
              from e in fo.elements("{urn:crystal-reports:schemas}value")
              select e.value),

Related Query

More Query from same tag