format problem query linq to xml

0

I do the following linq query on an xml file, and it shows me this result, how can I remove the keys and the text (code =), I am programming on asp.net c #.

this is the linq query

var q = (from r in LicitacionesD.Descendants("Licitacion")
                     where r.Element("CodigoEstado").Value == "8"
                     select new
                     {
                         codigo = r.Element("CodigoExterno").Value + " " + r.Element("Nombre").Value

                     });
    
asked by leonoscuro 23.05.2016 в 19:04
source

1 answer

0

You can only build the text as C # IEnumerable<string> with the query

from r in LicitacionesD.Descendants("Licitacion")
                     where r.Element("CodigoEstado").Value == "8"
                     select r.Element("CodigoExterno").Value + " " + r.Element("Nombre").Value

If you know that there is only one element or if you only want to find the first element you can use

string codigo = (from r in LicitacionesD.Descendants("Licitacion")
                         where r.Element("CodigoEstado").Value == "8"
                         select r.Element("CodigoExterno").Value + " " + r.Element("Nombre").Value).FirstOrDefault();
    
answered by 29.05.2016 / 22:39
source