3 * synopsis: Parse an XML document in memory to a tree and free it
4 * purpose: Demonstrate the use of xmlReadMemory() to read an XML file
5 * into a tree and and xmlFreeDoc() to free the resulting tree
8 * author: Daniel Veillard
9 * copy: see Copyright for the status of this software.
13 #include <libxml/parser.h>
14 #include <libxml/tree.h>
16 static const char *document = "<doc/>";
20 * @content: the content of the document
21 * @length: the length in bytes
23 * Parse the in memory document and free the resulting tree
26 example3Func(const char *content, int length) {
27 xmlDocPtr doc; /* the resulting document tree */
30 * The document being in memory, it have no base per RFC 2396,
31 * and the "noname.xml" argument will serve as its base.
33 doc = xmlReadMemory(content, length, "noname.xml", NULL, 0);
35 fprintf(stderr, "Failed to parse document\n");
43 * this initialize the library and check potential ABI mismatches
44 * between the version it was compiled for and the actual shared
49 example3Func(document, 6);
52 * Cleanup function for the XML library.
56 * this is to debug memory for regression tests