c# - Write LINQ to parse aspx page using HtmlAgilityPack -


I have seen the following and similar links on SO and Google to parse the ASPX page using HTML AggregatePack

But I do not know how to write the LINQ statement that I can identify buttons and label control names in my aspx page.

Here is my aspx page.

  & lt;% @ Page language = "C #" AutoEventWireUp = "True" CodeBhind = "webform 4.aspx.cs" Inherits = "WebApplication1.WebForm4"%> & Lt ;; DOCTYPE HTML PUBLIC "- // W3C // DTT XHTML 1.0 Transcription // N" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> & Lt; Html xmlns = "http://www.w3.org/1999/xhtml" & gt; & Lt; Head runat = "server" & gt; & Lt; Title & gt; & Lt; / Title & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; Form id = "form1" runat = "server" & gt; & Lt; Div & gt; & Lt; ASP: Button ID = "Button 1" Run = "Server" Text = "Button on Page4" /> & Lt; Br / & gt; & Lt; Br / & gt; & Lt; ASP: label ID = "label 1" run = "server" text = "label on page 4" & gt; & Lt; / Asp: Label & gt; & Lt; Br / & gt; & Lt; Br / & gt; & Lt; ASP: Button ID = "Button 2" Runat = "Server" Text = "Second Button Page 4" /> & Lt; Br / & gt; & Lt; ASP: Button ID = "Button 3" Runat = "Server" Text = "Second Button Page 4" /> & Lt; / Div & gt; & Lt; / Form & gt; & Lt; / Body & gt; & Lt; / Html & gt;   

I want to use LINQ as the HTML agility pack such that I can list the following output:

On this page there are controls button 1 , Label 1, button2, button3

I have a problem writing LINQ to parse the ASPX page. Please help me.

Even I have written so far and it is not working

  htmlgilitypack HTML document htmlDoc = new HTMLGilityPack.HMML document (); HtmlDoc.OptionFixNestedTags = True; String filePath = @ "C: \ WebApplication1 \ webform4.aspx"; Htmldoc.load (filepath); Htmldoc.load (filepath); Select links.Attributes.Contains ("runat") links from the link in Var pagecontrols = htmlDoc.DocumentNode.Descendants ("div"). Attribute ["id"]. Values; Foregoing (Win Page Control in PageRunt) {response. }    

If I understand your problem correctly, then you do something like Required: Select links.Attributes.Contains ("runat") links from links in

  var pagecontrols = htmlDoc.DocumentNode.Descendants ("div"). Attribute ["id"]. Values;    

Comments

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -