Zig
Zig
Using CDATA in XML
See more XML Examples
Demonstrates how to force the content of a node to be encapsulated in CDATA.The output of the following program is an XML document that looks like this:
<root>
<year>2009</year>
<junk1>abc .. < & > 123</junk1>
<junk2><![CDATA[abc .. < & > 123]]></junk2>
</root>
Chilkat Zig Downloads
const std = @import("std");
const chilkat = @import("chilkat");
pub fn main(init: std.process.Init) !void {
const alloc = init.arena.allocator();
const xml = try chilkat.Xml.init();
defer xml.deinit();
xml.setTag("root");
const child1 = try xml.newChild("year", "2009");
defer child1.deinit();
const child2 = try xml.newChild("junk1", "abc .. < & > 123");
defer child2.deinit();
const child3 = try xml.newChild("junk2", "abc .. < & > 123");
defer child3.deinit();
child3.setCdata(true);
std.debug.print("{s}\n", .{try xml.getXml(alloc)});
}