Hi I have this following code for C#.Net
ASCIIEncoding encoding = new ASCIIEncoding();
string postData = "membershipcardnumber=" + Cardnumber;
postData += ("&terminalname=" + TerminalName);
postData += ("&serviceid=" + CasinoID);
byte[] data = encoding.GetBytes(postData);
HttpWebRequest myRequest =
(HttpWebRequest)WebRequest.Create("http://myurl");
myRequest.Method = "POST";
myRequest.ContentType = "application/x-www-form-urlencoded";
myRequest.ContentLength = data.Length;
Stream newStream = myRequest.GetRequestStream();
newStream.Write(data, 0, data.Length);
HttpWebResponse response = (HttpWebResponse)myRequest.GetResponse();
// Get the stream associated with the response.
Stream receiveStream = response.GetResponseStream();
// Pipes the stream to a higher level stream reader with the required encoding format.
StreamReader readStream = new StreamReader(receiveStream, Encoding.UTF8);
Console.WriteLine("Response stream received.");
var egm_response = readStream.ReadToEnd();
Console.WriteLine(egm_response);
the variable egm_response
outputs the entire html code. This is just a part of it:
<div class="result" style="margin-left: 20px;">
<p>JSON Result :</p>
{"CreateEgmSession":{"IsStarted":0,"DateCreated":"","TransactionMessage":"Terminal already has an active session.","ErrorCode":37}} </div>
<div class="clear"></div>
How can I get or parse this html and only get the value after ErrorCode
?