Sample code for 30+ languages & platforms
Rust

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 Rust Downloads

Rust

// Note: This example requires the Chilkat Bundle license.

// Any string argument automatically begins the 30-day trial.
let glob = chilkat::Global::new();
if glob.unlock_bundle("30-day trial").is_err() {
    println!("{}", glob.last_error_text());
    return;
}

let http = chilkat::Http::new();

let html = http.quick_get_str("http://www.intel.com/").unwrap_or_default();
if !http.last_method_success() {
    println!("{}", http.last_error_text());
    return;
}

let html_to_xml = chilkat::HtmlToXml::new();

// Indicate the charset of the output XML we'll want.
html_to_xml.set_xml_charset("utf-8");

// Set the HTML:
html_to_xml.set_html(&html);

// Convert to XML:
let xml = html_to_xml.to_xml().unwrap_or_default();

// Save the XML to a file.
// Make sure your charset here matches the charset
// used for the XmlCharset property.
let _ = html_to_xml.write_string_to_file(&xml, "qa_output/out.xml", "utf-8").is_ok();

println!("Finished.");