Stack Exchange
VS 2012 LINQ to XML XmlDocument.Descendants causes "Try specifying type arguments explicitly"
I am making a simple LINQ Query against an XmlDocument and I get the "Try specifying type arguments explicitly" error.  Here is my C# code:
var Document = new XmlDocument();
Document.LoadXml(XmlFilePath);
var selectedMessage = from msg in Document.Descendants("Messages").Descendants("Message")
                      where msg.Attribute("Code").Value == constant
                      select msg;

The xml looks as follows:
<?xml version="1.0" encoding="utf-8" ?>
<MessageService>
   <Messages>
     <Message Code="DE-01003" Section="Delphi Backend" Line="N/A" Claim="No" Constant="E_PHY_LN_INV_HCPCS" Description="Error reading HCPCS code on line %d (%s)" />
     <Message Code="DE-01004" Section="Delphi Backend" Line="N/A" Claim="No" Constant="E_PHY_LN_RBRVS_FAMILY_INV_DT" Description="RunFamilyReduction: Invalid Date on claim line %d (%s)" />
     <Message Code="DE-02002" Section="Delphi Backend" Line="N/A" Claim="No" Constant="E_AMB_LN_INV_HCPCS" Description="Invalid or missing HCPCS code on claim line %d (%s)" />
     .
     .
     .
   </Messages>
</MessageService>

The first call to .Descendants causes the error.  I am not sure what I am doing wrong.   
Any help would be appreciated.
Thanks!
Susan

You're using XmlDocument, but attempting to use a Descendants method... and I expect you're thinking of XDocument.Descendants.
Is there any reason you want to use XmlDocument instead of LINQ to XML? Mixing and matching isn't going to be ideal...
Just change the first couple of lines to:
// Variable name casing changed to be more idiomatic
var document = XDocument.Load(xmlFilePath);


Can I load and external Xml document into an XDocument?   I didn't think so.  I thought I had to start with an XmlDocument.

Document is actually a property in a subclass I just simplified it for the example.  And XDocument does not have a Load Method.

@user1818345: Yes, absolutely. You don't need to use XmlDocument at all.

@user1818345: Um, yes it does: http://msdn.microsoft.com/en-us/library/system.xml.linq.xdocument.load.aspx

It is static Duh on my part!
