Lua
Lua
Download HTML from URL and Convert to XML
See more HTML-to-XML/Text Examples
Downloads an HTML page from a URL and converts it to XML.Chilkat Lua Downloads
local chilkat = require("chilkat")
-- Note: This example requires the Chilkat Bundle license.
-- Any string argument automatically begins the 30-day trial.
local glob = chilkat.Global.new()
local success = glob:unlock_bundle("30-day trial")
if not success then
print(glob.last_error_text)
return
end
local http = chilkat.Http.new()
local html = http:quick_get_str("http://www.intel.com/")
if not http.last_method_success then
print(http.last_error_text)
return
end
local htmlToXml = chilkat.HtmlToXml.new()
-- Indicate the charset of the output XML we'll want.
htmlToXml.xml_charset = "utf-8"
-- Set the HTML:
htmlToXml.html = html
-- Convert to XML:
local xml = htmlToXml:to_xml()
-- Save the XML to a file.
-- Make sure your charset here matches the charset
-- used for the XmlCharset property.
success = ERROR: Method not in Chilkat for Lua: HtmlToXml.WriteStringToFile
htmlToXml:ERROR()
print("Finished.")