ASP.NET/C#: Check if number inside HTML is less than 5

I use the following code to test if a website contains the text: "xyz":
String strResult;
WebResponse objResponse;
WebRequest objRequest = HttpWebRequest.Create("");
objResponse = objRequest.GetResponse();
using (StreamReader sr = new StreamReader(objResponse.GetResponseStream()))
    strResult = sr.ReadToEnd();
if (strResult.Contains("xyz"))
else {


Open in new window

How can I test if this block of code contains a number that is less than 5?
<li><span class="floatLeft">Views:</span><span class="floatNone">0</span></li>

Open in new window

LVL 10
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

anarki_jimbelSenior DeveloperCommented:
Not sure if I understand your question.

You need to parse your string and check the value. E.g., something like below.
I didn't do all required checks etc, this is just a sample.

        static void Main(string[] args)

            string block = "<li><span class=\"floatLeft\">Views:</span><span class=\"floatNone\">0</span></li>";

            int spanOpenStartIndex = -1;
            int spanOpenEndIndex = -1;
            int spanCloseStartIndex = -1;
            string value = null;

            spanOpenStartIndex = block.LastIndexOf("<span");
            spanOpenEndIndex = block.IndexOf(">", spanOpenStartIndex);
            spanCloseStartIndex = block.LastIndexOf("</span>");
            value = block.Substring(spanOpenEndIndex + 1, spanCloseStartIndex - spanOpenEndIndex-1);

                int result = int.Parse(value);
                if (result < 5)
                    Console.WriteLine("The result '" + result + "' is less than 5");
                    Console.WriteLine("The result '" + result + "' is greater than 5");

                Console.WriteLine("Unable to parse '{0}'", value);



Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.