Sample code for 30+ languages & platforms
Ruby

Load XML from a Remote URL

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

Chilkat Ruby Downloads

Ruby
require 'chilkat'

success = false

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

http = Chilkat::CkHttp.new()
sbXml = Chilkat::CkStringBuilder.new()

# Download the XML from the URL into sbXml
success = http.QuickGetSb("https://www.chilkatsoft.com/hamlet.xml",sbXml)
if (success == false)
    print http.lastErrorText() + "\n";
    exit
end

xml = Chilkat::CkXml.new()

# Load the XML contained in sbXml
success = xml.LoadSb(sbXml,true)
if (success == false)
    print xml.lastErrorText() + "\n";
    exit
end

print "Success." + "\n";