Since your data elements occur after the <div class=ls> tag and before
the next <br> tag, you can extract the data using a while loop as
follows.
********************
using System;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string htmlContent = "<table cellpadding=0 cellspacing=0
width=300 border=2><tr><td colspan=4><div
class=ls>NAME1<br></div></td></tr></div></td></tr><td width=100
class=in valign=top><div class=ls>ADDRESS1<br><tr><td colspan=4><div
class=ls>NAME2<br></div></td></tr></div></td></tr><td width=100
class=in valign=top><div class=ls>ADDRESS2<br><tr><td colspan=4><div
class=ls>NAME3<br></div></td></tr></div></td></tr><td width=100
class=in valign=top><div class=ls>ADDRESS3<br>";
string tokenStart = "<div class=ls>";
string tokenEnd = "<br>";
string name = String.Empty;
string address = String.Empty;
int endPosition = 0;
int startPosition = 0;
while (endPosition < htmlContent.Length - tokenEnd.Length)
{
startPosition = htmlContent.IndexOf(tokenStart,
endPosition) + tokenStart.Length;
endPosition = htmlContent.IndexOf(tokenEnd,
startPosition);
name = htmlContent.Substring(startPosition, endPosition
- startPosition);
startPosition = htmlContent.IndexOf(tokenStart,
endPosition) + tokenStart.Length;
endPosition = htmlContent.IndexOf(tokenEnd,
startPosition);
address = htmlContent.Substring(startPosition,
endPosition - startPosition);
Console.WriteLine("name = {0}, address = {1}", name,
address);
}
Console.ReadLine();
}
}
}
********************
When run this code results in the following output:
name = NAME1, address = ADDRESS1
name = NAME2, address = ADDRESS2
name = NAME3, address = ADDRESS3