I have a control that will return some html to me as a string. Before putting that on screen, I’d like to be able to tell if it’ll just show as empty.
For example the control might return <p><br /></p>, which when I test using C# for string.Emtpy obviously it’s not – but nothing gets displayed on screen.
Is there a regex function to test whether html will actually show any text on screen? Or using C# – is there any function to test the string containing html to see whether it actually contains anything other than tags?
Cheers, I’m a little confused how to get around this without writing some custom parser, a road I don’t want to have to go down!
As answered by @Ignacio you should use something like the HTML Agility pack. Here’s a sample bit of code that seems to work for your situation.
Note: This sample uses the http://html-agility-pack.net/?z=codeplex parser.