71371

How to read html table in c# [closed]

<table id="mytable" runat="server"> <thead> <tr> <td > </td> <td> Minute </td> <td Category Name </td> </tr> </thead> <tbody> <tr> <td > 10 </td> <td> </td> <td> <span></span> </td> </tr> <tr > <td> </td> <td> 15 </td> <td> <span></span> </td> </tr> </table>

This is my html table Here i have to find first cell second cell third cell data of each row in c# How can i find.

Answer1:

You may try Html agility pack API to parse the html text.

Answer2:

One option is to make the cells into server controls by adding an id and runat=server attributes and then you can access them as htmlcontrols - http://msdn.microsoft.com/en-us/library/system.web.ui.htmlcontrols.htmlcontrol.aspx

You could then use a repeater to generate each row. Then create a method for the ItemDataBound event of the repeater - http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.repeater.itemdatabound.aspx

This allows you to populate the data initially from a suitable data source and if your data source changes, you can simply rebind the source to the repeater to get it to update.

Example of how to find span tag :

<span id="span1" runat="server"></span>

Add the attributes as above.

Then within the repeater ItemDataBound method

e.Item.FindControl("span1")).innerText= "Hello John";

Note the use of the innerText method to add content within the span tags.

You only need to make the specific elements you need into server controls.

Recommend

  • Function object is not subscriptable in Python?
  • Html Agility Pack appending thead tbody tfoot in existing html table
  • HTML find and replace href tags [duplicate]
  • Get all elements matching an XPath expression in a webbrowser document
  • Redirect to trailng slash (htaccess)
  • How to make nicEditor snaplet? (Several questions)
  • Is there a Windows socket API call / option to “block” a range of ports à la SO_EXCLUSIVEADDRUSE
  • cell spacing in div table
  • Compress a file with GZipStream while maintaining its meta-data
  • Enabling DTD support in Sql Server
  • UWP/C# - Issue with AQS and USB Devices
  • Excel's Macro-Recorder usage
  • How to define custom class, title, and target in Link Browser for content elements and the new rte_c
  • How do I access an unhandled exception in an MVC Error view?
  • How to attach a node.js readable stream to a Sendgrid email?
  • Google Custom Search with transparent background
  • how to adjust image in a panel in Java swing?
  • Java Scanner input dilemma. Automatically inputs without allowing user to type
  • Retrieving value from sql ExecuteScalar()
  • Master page gives error
  • Excel - Autoshape get it's name from cell (value)
  • MySQL WHERE-condition in procedure ignored
  • vba code to select only visible cells in specific column except heading
  • Hazelcast - OperationTimeoutException
  • Web-crawler for facebook in python
  • align graphs with different xlab
  • RestKit - RKRequestDelegate does not exist
  • Unanticipated behavior
  • using conditional logic : check if record exists; if it does, update it, if not, create it
  • How to get icons for entities from eclipse?
  • Revoking OAuth Access Token Results in 404 Not Found
  • trying to dynamically update Highchart column chart but series undefined
  • Proper way to use connect-multiparty with express.js?
  • Load html files in TinyMce
  • Can't mass-assign protected attributes when import data from csv file
  • sending mail using smtp is too slow
  • JaxB to read class hierarchy
  • Unable to use reactive element in my shiny app
  • To Get the radio button value in ruby on rails
  • java string with new operator and a literal