Sample code for 30+ languages & platforms
Unicode C++

Download HTML from URL and Convert to XML

See more HTML-to-XML/Text Examples

Downloads an HTML page from a URL and converts it to XML.

Chilkat Unicode C++ Downloads

Unicode C++
#include <CkGlobalW.h>
#include <CkHttpW.h>
#include <CkHtmlToXmlW.h>

void ChilkatSample(void)
    {
    bool success = false;

    // Note: This example requires the Chilkat Bundle license.

    // Any string argument automatically begins the 30-day trial.
    CkGlobalW glob;
    success = glob.UnlockBundle(L"30-day trial");
    if (success != true) {
        wprintf(L"%s\n",glob.lastErrorText());
        return;
    }

    CkHttpW http;

    const wchar_t *html = 0;
    html = http.quickGetStr(L"http://www.intel.com/");
    if (http.get_LastMethodSuccess() != true) {
        wprintf(L"%s\n",http.lastErrorText());
        return;
    }

    CkHtmlToXmlW htmlToXml;

    // Indicate the charset of the output XML we'll want.
    htmlToXml.put_XmlCharset(L"utf-8");

    // Set the HTML:
    htmlToXml.put_Html(html);

    // Convert to XML:
    const wchar_t *xml = 0;
    xml = htmlToXml.toXml();

    // Save the XML to a file.
    // Make sure your charset here matches the charset
    // used for the XmlCharset property.
    success = htmlToXml.WriteStringToFile(xml,L"qa_output/out.xml",L"utf-8");

    wprintf(L"Finished.\n");
    }