dom - htmlagilitypack invalid cast exception when grabbing nodes with certain classes -
I want to capture the And I get this exception What I need to do now to do this, it is to work. Calculates the code of , not just one node (where you are using where, which matches all the items ). If you are interested only in the first item, use Such: Or assign to a count of HtmlNode: div objects from a HTML page that contains some class types I am:
HtmlNode authorNode = (HtmlNode) doc.DocumentNode.Descendants ("div"). Where (d = & gt; d.Attributes.Contains ("class") & amp;;; d.Attributes ["class"]. Value.Split (''). Any (B = & gt; B E.L. ("bineline") and B. E.L. ("list-pipe"));
System The unauthorized cost extension was unrestricted. HResult = -2147467262 Message = Unable to remove type object 'Type' whereEnumerableIterator`1 [HtmlAgilityPack HtmlNode] 'to type' HtmlAgilityPack.HtmlNode 'source = Project 1 StackTrace: Project 1. Scrapper C: \ User \ Jürber \ Document \ Visual Studio 2010 \ Project \ Project 1 \ Project 1 \ Scrapper CS: Project 1 on Line 233 in ProcciIarticle (String Yury). Scrapper ProcessNode (String Yuri), HtmlNode parentNode) C: \ Users \ jgarber \ Documents \ Visual Studio 2010 \ Projects \ Project1 \ Project1 \ Scraper.cs: Row 194 Project1.Scraper.ExecuteScraping () in C: \ Users \ jgarber \ Documents \ Visual Studio 2010 \ Projects \ Project1 \ Project1 \ Scraper.cs: Row 107 in Project 1. WebsprapingMain.Main () in C: \ Users \ jgarber \ Documents \ Visual Studio 2010 \ Projects \ Project1 \ Project1 \ WebscrapingMain.cs: On line 64 systems .AppDomain._nExecuteAssembly (Runtime assembly, string [] AGR). System on AppDomain.ExecuteAssembly (string assembly file, proof assembly security, string [] args) at Microsoft. Visual Studio Hosting Process.HostProR RUAsersSambands () on systems. threading. ThreadHalper ThreadStart_Context (Object State) System. Threading on Execution Contains System.Threading.ExecutionContext.Run (ExecutionContext Execution Context, Context Callback Callback, Object State) on the RuNian (Execution Contest Execution System.Threading.ExecutionContext.Run (ExecutionContext execution context, context callback callback, object state, Boolean protected) But ext, ContextClallback callback, Object state, Boolean protected sync syntax) in system. threading. ThreadHalper Thread Start () Inner Expption:
HtmlNode ;
first or
first and default or if you know to be only one item, then
Simply use or
SingleAora default instead of just
where .
HtmlNode authorNode = doc.DocumentNode.Descendants ("div"). Where (D => D. Features. Consistency ("Class") & amp; A Features ["Square"] Value Sample (''). Any (B = & gt; B. Eckels "Biline") & amp; amp; B. Eulles ("list-pipe")). FirstOver Default ();
IEnumerable & lt; HtmlNode & gt; authorNodes = doc.DocumentNode.Descendants ("div"). Where (D = & gt; Properties are included ("square") & amp; A characteristic ["class"] value. Sample (''). Any (B => Ecklace ("bline") and B. Eccles ("list-pipe"));
Comments
Post a Comment