Following the discussion:541059, I was able to get the XML body of the response into wstring. Full example looks like this.
#include <cpprest/filestream.h>
using namespace utility; // Common utilities like string conversions
using namespace web; // Common features like URIs.
using namespace web::http; // Common HTTP functionality
using namespace web::http::client; // HTTP client features
using namespace concurrency;
using namespace concurrency::streams;
void output_longlat_for_address(const std::wstring & address)
{
// Create the client, build the query, and start the request.
http_client client(L"http://api4.mapy.cz/");
uri_builder builder(L"/geocode");
builder.append_query(L"query", address);
client.request(methods::GET, builder.to_string())
.then([](http_response response)
{
// Headers arrived.
return response.extract_string();
}).then([](utility::string_t responseBody)
{
// Body arrived.
std::wcout << responseBody;
}).wait();
}
int main()
{
output_longlat_for_address(L"Vítězství 27, Olomouc");
return 0;
}
Now, my goal is to extract longitude and latitude info (geocoding service) from the XML. I have read elsewhere that XmlLite can be a good way to parse the result. However, I did not find any example on how Casablanca can be put together with XmlLite. Is there any recommended way of probably redirecting the body stream into the parser?