Hi, im writing a piece of code that reads an HTML source code file. The code is meant to read the HTML and pick out stock symbols. It seems to work fine but as soon as it finds the first stock ticker, the program stops. Ideally, it should find all the stock tickers (There can be upto 25 symbols in the html code).
What am i doing wrong? I would appreciate any help. My C# code is posted below:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Web;
using System.IO;
using System.Net;
using System.Text.RegularExpressions;
using System.Text;
using System.Diagnostics;
namespace pinksheets2
{
class Program
{
static void Main(string[] args)
{
System.IO.StreamReader file = new System.IO.StreamReader("c:\\dlist.txt");
// dump streamreader contents to string
string strContent = file.ReadToEnd();
Console.WriteLine(strContent);
// search string
string startStr = "../quote/quote.jsp?symbol=";
// end string
String endStr = ">";
int startIndex;
int endIndex;
string record = null;
String str = null;
while ((record = strContent) != null)
{
startIndex = record.IndexOf(startStr);
if (startIndex != -1)
{
endIndex = record.IndexOf(endStr, startIndex);
if (endIndex != -1)
{
int length = endIndex - startIndex;
str = record.Substring(startIndex, length);
Console.WriteLine(str);
string words2 = str;
string[] split = str.Split(new Char[] { ' ', ',', '.', ':', '=', '>' });
Console.WriteLine("symbol is:" + split[4]);
Console.Read();
}
}
}
}
}
}
I can post the html code too if needed.
TIA