When you work with word xml files and locate a field in the schema what
you read usually contains XML decorating tags that most probably you don’t need
them in your code. How can we get rid of them?
It is pretty simple. Brush up your .NET knowledge and remember we have a class
called Regex which is a short name for Regular Expression object. Using Regex
you can simply define a pattern for XML or HTML tags. This pattern will be
something like this: "<[^>]*>".
The very same Regex class has Replace function that works just like Replace in
String class. Having them all together in C# you will have a code like this:
public string
RemoveTags(String originalMessage)
{
Regex rgx =
new Regex("<[^>]*>");
return
rgx.Replace(originalMessage, "");
}
This function simply gets an HTML/XML String and returns pure text. Don’t forget
to add
using
System.Text.RegularExpressions;
to your file header.
Enjoy
Alireza