0

The value of html is stored in string. I need to parse the html and get the html values of tr's with only that are checked. For example, In the html snippet below, I need to get only tr that are checked.

<table>
<tr>
 <th></th>
 <th>Day</th>
 <th>Code</th>
</tr>
<tr>
 <td><input type="checkbox" id="GridVeiw1_c1_checkbox1" type="checkbox" /></td>
 <td>Sunday</td>
 <td>ABCD</td>
</tr>

<tr>
 <td><input type="checkbox" id="GridVeiw1_c2_checkbox1" type="checkbox" checked="checked" /></td>
 <td>Monday</td>
 <td>ABCD</td>
</tr>

<tr>
 <td><input type="checkbox" id="GridVeiw1_c3_checkbox1" type="checkbox" /></td>
 <td>Tuesdat</td>
 <td>ABCD</td>
</tr>

</table>

For the above I need rows only with checked="Checked". Sample output as below

<table>
<tr>
 <th></th>
 <th>Day</th>
 <th>Code</th>
</tr>

<tr>
 <td><input type="checkbox" id="GridVeiw1_c2_checkbox1" type="checkbox" checked="checked" /></td>
 <td>Monday</td>
 <td>ABCD</td>
</tr>



</table>
Jhjry smth
  • 197
  • 1
  • 1
  • 12
  • Your HTML is invalid - you have unclosed `id=""` attributes in the `` elements so you won't be able to easily use regular-expressions to extract values. – Dai Mar 14 '17 at 19:27
  • 2
    Invalid HTML is a great argument in favor of using a pre-existing library that can handled mangled HTML properly. But...your question shows now research effort. It sounds like you just want us to write the code for you to get what you want? – mason Mar 14 '17 at 19:28
  • Possible duplicate of [Parsing HTML to get content using C#](http://stackoverflow.com/questions/2038104/parsing-html-to-get-content-using-c-sharp) – confusedandamused Mar 14 '17 at 19:29
  • @Dai I've edited the post, I missed ' " ' at the ending of the id – Jhjry smth Mar 14 '17 at 19:34
  • Oh so many ways to solve this from a regex to simple string searching and manipulation depending on how it's going to be used. What have you tried so far? – Allan S. Hansen Mar 14 '17 at 20:00
  • I like Jquery for this type of thing. But that's Javascript... – Trey Mar 14 '17 at 20:16
  • 1
    If this is related to [this question](http://stackoverflow.com/questions/42792444/how-to-get-html-portion-of-the-selected-row-in-the-gridview), i've modified the anwer to filter out the rows with the checked checkbox. – VDWWD Mar 14 '17 at 22:44

0 Answers0