Linq To Xml

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
displaying my weak understanding of Linq to Xml and asking for help. I was trying to do this cast and then do a query.

<div style="border-right:#7f9db9 1px solid;border-top:#7f9db9 1px solid;font-size:11px;overflow:auto;border-left:#7f9db9 1px solid;line-height:100%! important;border-bottom:#7f9db9 1px solid;font-family:Courier New;background-color:white
<table style="border-top-width:0px;border-left-width:0px;margin:2px 0px;width:99%;border-bottom:#eee 0px solid;border-collapse:collapse;background-color:#fff;border-right-width:0px" cellspacing=0 cellpadding=0>
<colgroup>
<col style="padding-left:10px;font-size:11px;border-bottom:#f7f7f7 1px solid;font-family:Courier New;white-space:nowrap
<tbody>
<tr>
<td><font style="font-size:11px XmlDocument </font><font style="color:red doc</font><font style="font-size:11px  = </font><font style="color:blue new</font><font style="font-size:11px  XmlDocument ( );  </font></td></tr>
<tr>
<td style="background-color:#f7f7f7                 doc.Load ( path );  </td></tr>
<tr>
<td>                XmlNodeList </font><font style="color:red rootNodeList</font><font style="font-size:11px  = </font><font style="color:blue doc</font><font style="font-size:11px .GetElementsByTagName ( "root" );  </font></td></tr>
<tr>
<td style="background-color:#f7f7f7                 XmlNode </font><font style="color:red rootNode</font><font style="font-size:11px  = </font><font style="color:blue rootNodeList</font><font style="font-size:11px .Item ( 0 );  </font></td></tr>
<tr>
<td>                System.Collections.IEnumerable </font><font style="color:red que</font><font style="font-size:11px  = ( System.Collections.IEnumerable )rootNode.ChildNodes.Cast</font><font style="color:blue <</font><font style="font-size:11px XmlNode</font><font style="color:blue ></font><font style="font-size:11px  ( );  </font></td></tr>
<tr>
<td style="background-color:#f7f7f7                    </td></tr>
<tr>
<td>                XmlNode elem;  </td></tr>
<tr>
<td style="background-color:#f7f7f7                 var </font><font style="color:red qMethods</font><font style="font-size:11px  = ( from elem in que  </font></td></tr>
<tr>
<td>                                 where </font><font style="color:red elem.Name</font><font style="font-size:11px  == this.ext + "Files_" + Globals.hostName  </font></td></tr>
<tr>
<td style="background-color:#f7f7f7                                  select elem ).Take ( 1 ); </td></tr></tbody></table> The error message (at compile) I am getting is as follows:

Error 1 Could not find an implementation of the query pattern for source type System.Collections.IEnumerable.  Where not found.  Consider explicitly specifying the type of the range variable elem. 

I also tried to cast it as IQueable with teh same result.

Thanks in advance.
<hr size="1" align="left" width="25% AlexB

View the full article
 
Back
Top