var query = from k in xDoc.Descendants("product")
select
new
{
KategoriKod =Convert.ToString( k.Element("cat1").Value) + Convert.ToString( k.Element("cat2").Value),
};
I want to take two elemens of an xml file by one variable. but I recieve this Error
“‘string’ does not contain a definition for ‘Value’ ”
any one help plz.?
The following works for me:
Here is the result:
{ KategoriKod = ABC123 }
{ KategoriKod = XYZ }
Press any key to continue . . .
Note that I used explicit conversion operator (casting elements to string) to avoid NullReferenceExceptions in when calling .Value on elements that do not exist.