Sandeep Bansal
Sandeep Bansal

Reputation: 6394

Remove Table from HTML or XAML C#

I have used a HTML to XAML (FlowDocument) conversion script, the only problem is that I don't want tables to be displayed.

I would prefer using the HTML code for this example:

<table>
<tr>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
</table>

OK just for examples sake, that is the formatting of the table, as it is. I would like to replace the tags with something maybe like a <p> or <br /> how would I go about doing this?

Upvotes: 1

Views: 1166

Answers (1)

George Johnston
George Johnston

Reputation: 32278

In very simplistic terms:

string html = "...";
html = html.Replace("<table>","<p>");
html = html.Replace("<td>","");
html = html.Replace("</td>"," ");
html = html.Replace("<tr>","");

html = html.Replace("</tr>","<br/>");
html = html.Replace("</table>","</p>");

You'll get an extra space after your closed in case you have more than one . You can account for this through more thorough logic.

Upvotes: 1

Related Questions