Click here to Skip to main content
15,041,788 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I want to export the content to word file which is in a div in my view page. Once when i tried, the word file got exported with html tags(div). How can i get rid of those html tag and show the exact content.Please provide sample code.

Thanks.
Posted

1 solution

You can use RegExp for it:
C#
public static string removeHtml(string input)
{
   return Regex.Replace(input, "<.*?>", String.Empty);
}

You can find more detailed snippet here[^].
And one article too, Remove all the HTML tags and display a plain text only inside (in case XML is not well formed)[^].
For exporting your div content to MS Word: Dynamically generate a MS Word document using HTML & CSS[^]

-KR
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900