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