Parsing a HttpResponse (C++)
Posted on 2010-08-24
I'm currently getting a Http response as a binary string and writing it to a log file (below). Instead I'd like to parse it as a string. E.g. if the response contains an XML tag <response>200</response> I'd like to parse that out.
How would I go about doing this?
HttpWebResponse^ httpResponse = nullptr;
BinaryReader^ httpResponseStream = nullptr;
httpResponse = (HttpWebResponse^)httpRequest->GetResponse();
httpResponseStream = gcnew BinaryReader(httpResponse->GetResponseStream(), Encoding::UTF8);
// Write Response To File
readData = httpResponseStream->ReadBytes(4096);
if (readData->Length == 0)
logFile->Write(readData, 0, readData->Length);