13:05 ET Dow -154.48 at 10309.92, Nasdaq -37.61 at 2138.44, S&P -19.130 1 100001 0 1 0 1 1 0 1 0 00 0 1 1 1 0 1 100001 0 1 1 100001 0 1 100001 0 1 0 1 1 0 1 0 00 0 1 1 1 0 1 100001 0 1 1 100001 0 1 100001 0 1 0 1 1 0 1 0 00 0 1 1 1 0 1 100001 0 1 1 100001 0 1 100001 0 1 0 1 1 0 1 0 00 0 1 1 1 0 1 100001 0 1 1 100001 0 1 100001 0 1 0 1 1 0 1 0 00 0 1 1 1 0 1 100001 0 1 1 100001 0 1 100001 0 1 0 1 1 0 1 0 00 0 1 1 1 0 1 100001 0 1 1 100001 0 1 100001 0 1 0 1 1 0 1 0 00 0 1 1 1 0 1 100001 0 1 1 100001 0 1 100001 0 1 0 1 1 0 1 0 00 0 1 1 1 0 1 100001 0 1 1 100001 0 1 100001 0 1 0 1 1 0 1 0 00 0 1 1 1 0 1 100001 0 1 1 100001 0 1 100001 0 1 0 1 1 0 1 0 00 0 1 1 1 0 1 100001 0 1 1 100001 0 1 100001 0 1 0 1 1 0 1 0 00 0 1 1 1 0 1 100001 0 1 1 100001 0 1 100001 0 1 0 1 1 0 1 0 00 0 1 1 1 0 1 100001 0 1 1 100001 0 1 100001 0 1 0 1 1 0 1 0 00 0 1 1 1 0 1 100001 0 1 1 100001 0 1 100001 0 1 0 1 1 0 1 0 00 0 1 1 1 0 1 100001 0 1 1 100001 13:05 ET Dow -154.48 at 10309.92, Nasdaq -37.61 at 2138.44, S&P -19.1313:05 ET Dow -154.48 at 10309.92, Nasdaq -37.61 at 2138.44, S&P -19.13

.

.

Wednesday, September 28, 2011

C# API Function to Parse XML Message

void ParseIt(byte[] bytes)
{
try
{
// All messages sent FROM QT Server start with a Record ID
string RecordID = System.Text.Encoding.UTF8.GetString(bytes, 0, 2);
string message = "";

switch (RecordID)
{
// Parse a Level 1 FULL QUOTE message
case "S1":
message = ParseS1(bytes);

// rich text boxes don't like multiple threads changing it at the same time
RichTextBoxAppendText(richTextBoxTicks, message);
break;

// Parse a Level1 UPDATE QUOTE message
case "L1":
message = ParseL1(bytes);
RichTextBoxAppendText(richTextBoxTicks, message);
break;

// Parse a HISTORY TICK record
case "HT":
message = ParseHT(bytes);
RichTextBoxAppendText(richTextBoxHistory, message);
break;

// Parse a HISTORY OHLC record
case "HO":
message = ParseHO(bytes);
RichTextBoxAppendText(richTextBoxHistory, message);
break;

// Parse a HISTORY END record
case "HE":
message = ParseHO(bytes);
RichTextBoxAppendText(richTextBoxHistory, message);
break;

// Parse a LOGIN feedback
case "LO":
message = ParseXML(bytes);
RichTextBoxAppendText(richTextServerResponse, message);
break;

// Parse a ER feedback
case "ER":
message = ParseXML(bytes);
RichTextBoxAppendText(richTextServerResponse, message);
break;

case "OK":
message = ParseXML(bytes);
RichTextBoxAppendText(richTextServerResponse, message);
break;

case "ST":
message = ParseXML(bytes);
RichTextBoxAppendText(richTextServerResponse, message);
break;


default:
//ParseXML(bytes);
break;
}
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
}