Swift
Swift
Load XML from a Remote URL
Demonstrates how to load XML from a remote URL, such as https://www.chilkatsoft.com/hamlet.xmlChilkat Swift Downloads
func chilkatTest() {
var success: Bool = false
// This example assumes the Chilkat HTTP API to have been previously unlocked.
// See Global Unlock Sample for sample code.
let http = CkoHttp()!
let sbXml = CkoStringBuilder()!
// Download the XML from the URL into sbXml
success = http.quickGetSb(url: "https://www.chilkatsoft.com/hamlet.xml", sbContent: sbXml)
if success == false {
print("\(http.lastErrorText!)")
return
}
let xml = CkoXml()!
// Load the XML contained in sbXml
success = xml.loadSb(sb: sbXml, autoTrim: true)
if success == false {
print("\(xml.lastErrorText!)")
return
}
print("Success.")
}