Sample code for 30+ languages & platforms
Tcl

Load XML from a Remote URL

Demonstrates how to load XML from a remote URL, such as https://www.chilkatsoft.com/hamlet.xml

Chilkat Tcl Downloads

Tcl

load ./chilkat.dll

set success 0

# This example assumes the Chilkat HTTP API to have been previously unlocked.
# See Global Unlock Sample for sample code.

set http [new_CkHttp]

set sbXml [new_CkStringBuilder]

# Download the XML from the URL into sbXml
set success [CkHttp_QuickGetSb $http "https://www.chilkatsoft.com/hamlet.xml" $sbXml]
if {$success == 0} then {
    puts [CkHttp_lastErrorText $http]
    delete_CkHttp $http
    delete_CkStringBuilder $sbXml
    exit
}

set xml [new_CkXml]

# Load the XML contained in sbXml
set success [CkXml_LoadSb $xml $sbXml 1]
if {$success == 0} then {
    puts [CkXml_lastErrorText $xml]
    delete_CkHttp $http
    delete_CkStringBuilder $sbXml
    delete_CkXml $xml
    exit
}

puts "Success."

delete_CkHttp $http
delete_CkStringBuilder $sbXml
delete_CkXml $xml