diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2015-02-04 14:09:54 +0100 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2015-02-04 14:09:54 +0100 |
commit | bd82d030011cd8b9655e5ded6b6df9343b42a6bd (patch) | |
tree | de82d886dfea0cb7dbb6e80436218a25cb211bc3 /src/tc-xml.c |
Imported Upstream version 3.22upstream/3.22
Diffstat (limited to 'src/tc-xml.c')
-rw-r--r-- | src/tc-xml.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/tc-xml.c b/src/tc-xml.c new file mode 100644 index 0000000..07cf3b3 --- /dev/null +++ b/src/tc-xml.c @@ -0,0 +1,35 @@ +/* + * 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 <stdbool.h> +#include <stdio.h> +#include <libxml/parser.h> +#include <libHX/defs.h> +#include <libHX/libxml_helper.h> + +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; +} |