I have a string that has a format like this:
<b>*GTPersonnel</b><table border=1><tr><td>ss2111</td></tr></table>
I want to process those data that is between <td> tags and replace each occurrence of &#Blah; with its equal character so for example in s I want it to be replaced by just the character a because 115 is the character code for that.
I can loop through the whole string, find &# index, find ; index, read the character in between and find the Character for that code… well it is a bit algorithmic… I was wondering if there are better things with .NET that I can utilize for this puprpose.
If you use
XHTMLyou can simple modify theEntityHandlingproperty inXmlTextReaderobject to tell it to handle character entities automatically:Then you can read your file with
XmlTextReaderor with the help ofLINQ to XML. For example, if you have xml file like this:And you write the code below above and next couple of strings:
You get
ss2111value on your console window.