Zig
Zig
Xml.ChildContent Example #2
Another Xml.UpdateChildContent example...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("abc");
const sb_value = try chilkat.StringBuilder.init();
defer sb_value.deinit();
var i: i32 = 0;
while (i < 10) {
xml.setI(i);
sb_value.clear();
sb_value.appendInt(i) catch {};
xml.updateChildContent("xyz|test[i]", try sb_value.getAsString(alloc));
i = i + 1;
}
std.debug.print("{s}\n", .{try xml.getXml(alloc)});
// Output is:
// <?xml version="1.0" encoding="utf-8" ?>
// <abc>
// <xyz>
// <test>0</test>
// <test>1</test>
// <test>2</test>
// <test>3</test>
// <test>4</test>
// <test>5</test>
// <test>6</test>
// <test>7</test>
// <test>8</test>
// <test>9</test>
// </xyz>
// </abc>
}