Quantcast
Channel: WE MOVED to github.com/microsoft/cpprestsdk. This site is not monitored!
Viewing all articles
Browse latest Browse all 4845

New Post: How to extract some info from the http_client response via XmlLite?

$
0
0
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?

Viewing all articles
Browse latest Browse all 4845

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>