Sample code for 30+ languages & platforms
Tcl

Load XML Object from HTTP Response Body

Demonstrates how to load the HTTP response body directly into an XML object.

Chilkat Tcl Downloads

Tcl

load ./chilkat.dll

set success 0

set http [new_CkHttp]

set resp [new_CkHttpResponse]

set success [CkHttp_HttpStr $http "GET" "https://www.chilkatsoft.com/exampledata/inventory.xml" "" "" "" $resp]
if {$success == 0} then {
    puts [CkHttp_lastErrorText $http]
    delete_CkHttp $http
    delete_CkHttpResponse $resp
    exit
}

set xml [new_CkXml]

# If we wish to transfer (instead of copy) the XML from the HttpResponse to the Xml, then add the keyword "TakeResponseBody" to UncommonOptions
# This could save memory for extremely large XML responses.
CkHttpResponse_put_UncommonOptions $resp "TakeResponseBody"

CkHttpResponse_GetBodyXml $resp $xml

puts [CkXml_getXml $xml]

# Note: If UncommonOptions contained "TakeResponseBody", then the response BodyStr will now be empty:
puts "----"
puts [CkHttpResponse_bodyStr $resp]

delete_CkHttp $http
delete_CkHttpResponse $resp
delete_CkXml $xml