+2  A: 

Well it looks like you're nearly there:

XDocument loaded = XDocument.Load(@"C:\Menu_Settings.xml");

var q = from c in loaded.Descendants("module")
        where (int)c.Attribute("ModuleID") < 0
        select new
        {
             Text = (string) c.Attribute("Text"),
             ModID = (string) c.Attribute("ModID"),
             ModuleID = (int) c.Attribute("ModuleID"),
             MenuType = (int) c.Attribute("MenuType"),
             Perm = (bool) c.Attribute("Perm")
        };

If that doesn't help you, please give more details.

Jon Skeet
Hi Jon, you're missing commas at the end of some lines here I think?
AndyC
@AndyC: Yup, will fix.
Jon Skeet
thanks for help ....
shamim
want to select all menu tag and AspxMenu fill by this value.menu tag contain leaf and submenu tag.How to select all value.
shamim
@shamim: I'm afraid I didn't follow that at all...
Jon Skeet
plz follow this url.There i describe my problme.http://stackoverflow.com/questions/3458700/how-to-aspxmenu-fill-from-xml-file
shamim
@shamim: It doesn't really - it just repeats the same phrase, which doesn't make sense. I realise English probably isn't our first language, but please make another attempt to describe what you're trying to do.
Jon Skeet
A: 

Or you can in the last step cast to XElement and use whatever XElement has to offer:

instead of var q:

IEnumerable<XElement> q =from c in loaded.Descendants("module") 
                    where (int)c.Attribute("ModuleID").Value < 0 
                    select c;

foreach(XElement e in q){
   string t = e.Attribute("Text").Value;
   // etc...
}

if you know one record is going to be return

XElement q = (from c in loaded.Descendants("module") 
                    where (int)c.Attribute("ModuleID").Value < 0 
                    select c).First(); // one of many options to return a single record

sring t = q.Attribute("Text").Value;
// etc...

UPDATE

to make further queries to your result:

IEnumarble<XElement> menus = q.Elements("menu");

then loop foreach, you can use menuselement.Element("tag_name").Value to get string values of the nodes, or menuselement.Attribute("attr_name").Value to get attribute values, and you can further query with menuslement.Find or menuselement.Where or menuselement.Select and the options are really limitless... here is where you can learn more: http://msdn.microsoft.com/en-us/library/bb387065.aspx

And here is MSDN's how to query xml using linq: http://msdn.microsoft.com/en-us/library/bb943906.aspx

Ayyash
im not 100% sure of (int) to cast, if it works for you great, but it never works for me, i usually have to go with Convert.toInt16(val)
Ayyash
How to select all menu tag values.Menu tag contain leaf,submenu tag's.want to select all values of the menu tag and fill AspxMenu by this value.
shamim