The attribute will not be equal to "456" - this is an attribute, not a string. However, if you convert it to a string first, it will work.
var feeds = from feed in xDoc.Descendants("Show")
where (string)feed.Attribute("Code") == "456"
select new
{
EventDate = feed.Attribute("Date").Value
};
An alternative would be intto make sure it is numeric:
var feeds = from feed in xDoc.Descendants("Show")
where (int) feed.Attribute("Code") == 456
select new
{
EventDate = feed.Attribute("Date").Value
};
EDIT: Okay, now I have this short but complete program to show how it works.
, , "" "", XML. , "" "" , "". , , , DateTime?. 1 (.. , "" ):
using System;
using System.Linq;
using System.Xml.Linq;
public static class Test
{
static void Main(string[] args)
{
XDocument xDoc = XDocument.Load("shows.xml");
var feeds = from feed in xDoc.Descendants("Show")
where (int) feed.Attribute("Code") == 456
select new
{
EventDate = (DateTime?) feed.Attribute("Date")
};
Console.WriteLine(feeds.Count());
}
}
, "from", :
var events = from feed in xDoc.Descendants("Show")
where (int) feed.Attribute("Code") == 456
from ev in feed.Elements("Event")
select new
{
EventDate = (DateTime?) ev.Attribute("Date")
};