Zig
Zig
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 Zig Downloads
const std = @import("std");
const chilkat = @import("chilkat");
pub fn main(init: std.process.Init) !void {
const alloc = init.arena.allocator();
var success: bool = false;
// Note: This example requires the Chilkat Bundle license.
// Any string argument automatically begins the 30-day trial.
const glob = try chilkat.Global.init();
defer glob.deinit();
glob.unlockBundle("30-day trial") catch {
std.debug.print("{s}\n", .{try glob.getLastErrorText(alloc)});
return;
};
const http = try chilkat.Http.init();
defer http.deinit();
const html = http.quickGetStr(alloc, "http://www.intel.com/") catch {
std.debug.print("{s}\n", .{try http.getLastErrorText(alloc)});
return;
};
const html_to_xml = try chilkat.HtmlToXml.init();
defer html_to_xml.deinit();
// Indicate the charset of the output XML we'll want.
html_to_xml.setXmlCharset("utf-8");
// Set the HTML:
html_to_xml.setHtml(html);
// Convert to XML:
_ = try html_to_xml.toXml(alloc);
// Save the XML to a file.
// Make sure your charset here matches the charset
// used for the XmlCharset property.
ERROR: Method not in the Zig package: HtmlToXml.WriteStringToFile
ERROR: Method not in the Zig package: HtmlToXml.WriteStringToFile
success = html_to_xml.ERROR();
std.debug.print("Finished.\n", .{});
}