Unicode C
Unicode C
Load XML from a Remote URL
Demonstrates how to load XML from a remote URL, such as https://www.chilkatsoft.com/hamlet.xmlChilkat Unicode C Downloads
#include <C_CkHttpW.h>
#include <C_CkStringBuilderW.h>
#include <C_CkXmlW.h>
void ChilkatSample(void)
{
BOOL success;
HCkHttpW http;
HCkStringBuilderW sbXml;
HCkXmlW xml;
success = FALSE;
// This example assumes the Chilkat HTTP API to have been previously unlocked.
// See Global Unlock Sample for sample code.
http = CkHttpW_Create();
sbXml = CkStringBuilderW_Create();
// Download the XML from the URL into sbXml
success = CkHttpW_QuickGetSb(http,L"https://www.chilkatsoft.com/hamlet.xml",sbXml);
if (success == FALSE) {
wprintf(L"%s\n",CkHttpW_lastErrorText(http));
CkHttpW_Dispose(http);
CkStringBuilderW_Dispose(sbXml);
return;
}
xml = CkXmlW_Create();
// Load the XML contained in sbXml
success = CkXmlW_LoadSb(xml,sbXml,TRUE);
if (success == FALSE) {
wprintf(L"%s\n",CkXmlW_lastErrorText(xml));
CkHttpW_Dispose(http);
CkStringBuilderW_Dispose(sbXml);
CkXmlW_Dispose(xml);
return;
}
wprintf(L"Success.\n");
CkHttpW_Dispose(http);
CkStringBuilderW_Dispose(sbXml);
CkXmlW_Dispose(xml);
}