Muhammad Imran Ansari

Muhammad Imran Ansari

  • 311
  • 6k
  • 276.5k

Remove Table from String HTML

Nov 7 2022 5:56 PM

Hi,

I have the following HTML, storing in a string in C# code (string html = "below html";).

There are five tables in HTML and I want to remove table tag from string where table id = 'Location2'. Please advise

<table style="width: 100%; background-color: white;">
	<tbody>
		<tr>
			<td style="background-color:#1741B0">NOTIFICATION</td>
		</tr>
	</tbody>
</table>
<table style="width: 100%; background-color: white;">
	<tr>		
		<tr>
			<td>Column-1</td>
			<td>Column-1 Value</td>
		</tr>
		<tr>
			<td>Column-2</td>
			<td>Column-2 Value</td>
		</tr>
	</tr>
</table>
<br/>	
<table id="Location1" style="font-size: 15px; font-family: sans-serif;">
	<tr>
		<td colspan="2">
			<b>Location-1</b>
		</td>
	</tr>
	<tr>
		<td>Name:</td>
		<td>Location Name</td>
	</tr>
	<tr>
		<td>AddrLine:</td>
		<td>Location Address</td>
	</tr>
</table>
<br/>
<table id="Location2" style="font-size: 15px; font-family: sans-serif;">
	<tr>
		<td colspan="2">
			<b>Location-2</b>
		</td>
	</tr>
	<tr>
		<td>Name:</td>
		<td>Location Name</td>
	</tr>
	<tr>
		<td>AddrLine:</td>
		<td>Location Address</td>
	</tr>
</table>
<br/>
<table id="Summary" style="font-size: 15px; font-family: sans-serif;">
	<tr>
		<td colspan="2">
			<b>Summary</b>
		</td>
	</tr>
	<tr>
		<td>Distance (Miles):</td>
		<td>150</td>
	</tr>
	<tr>
		<td>Distance (Meter):</td>
		<td>200</td>
	</tr>
</table>

 


Answers (3)