using Xml; namespace test { static int main (string[] args) { /* build doc */ var d = new Doc(); var _r = new Node(null, "root"); weak Ns ns = _r.new_ns("http://localhost/myns.dtd", "myns"); weak Node r = _r; d.set_root_element(#_r); /* add nodes */ r.new_child(null, "title", "Hi!"); weak Node a = r.new_child(null, "attrs_test"); a.set_prop("t1", "value of t1"); a.set_ns_prop(ns, "t2", "value of t2 with ns"); weak Node c = r.new_child(ns, "node_with_child"); c.new_child(null, "child", "Child text!"); /* test xmlChar* is freed properly and that string methods can be used */ xmlstring mem; int len; d.dump_memory_format(out mem, ref len, true); GLib.stdout.printf("len = %d\nstrlen = %d\n\n%s\n", len, mem.size(), mem); /* test default args */ mem = null; d.dump_memory_format(out mem); GLib.stdout.printf("\n%s\n", mem); /* test save */ d.save_file("test.xml"); d.save_file_format("test-formatted.xml", true); /* test Instance(position = 2) */ d.save_file_enc_format("test-formatted-encoded.xml", "UTF-8", true); d.set_compress_mode(1); d.save_file_format("test-formatted-encoded.xml.gz"); return 0; } }