/* * Copyright Jan Engelhardt * * This program is free software; you can redistribute it and/or * modify it under the terms of the WTF Public License version 2 or * (at your option) any later version. */ #include #include #include #include #include int main(void) { xmlDoc *doc; xmlNode *root, *etc, *node; char *result = NULL; int size = 0; doc = xmlNewDoc(NULL); root = xmlNewDocNode(doc, NULL, "root", NULL); xmlDocSetRootElement(doc, root); xml_newnode(root, "empty", NULL); etc = xml_newnode(root, "filled", NULL); xml_newnode(etc, "a", "1234 bytes"); node = xml_newnode(etc, "b", "0 bytes"); xml_newnode(node, "extra", NULL); xmlDocDumpFormatMemory(doc, reinterpret_cast(xmlChar **, &result), &size, true); xmlSaveFileEnc("test.xml", doc, "utf-8"); if (result != NULL) printf("%.*s\n", size, result); return 0; }