axl main logo
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Modules Pages
axlDoc * axl_doc_create ( const char *  version,
const char *  encoding,
axl_bool  standalone 

Creates a new empty xml document, especifying options to be used in the header.

This function allows to create the xml document representation the must be used to add childs to it.

The following is a simple example that creates a xml document (axlDoc) with a single root node (axlNode):

1 // some variables
2 axlDoc * doc;
3 axlNode * node;
5 // dump content variables
6 char * content;
7 int content_size;
9 // create the document
10 doc = axl_doc_create (NULL, NULL, axl_true);
12 // create the root document node
13 node = axl_node_create ("root-node");
15 // configure it as the root
16 axl_doc_set_root (doc, node);
18 // dump pretty
19 axl_doc_dump_pretty (doc, &content, &content_size, 4);
21 // print the content and free
22 printf ("document size=%d, content: %s\n", content_size, content);
23 axl_free (content);
versionThe xml document version. This value is optional. If NULL is used, the library will use "1.0" as version value.
encodingThe document encoding to be used. This value is optional, if NULL is provided, no encoding specification will be used.
standaloneStandalone configuration flag. By default, use axl_false.
Returns a newly allocated axlDoc instance that must be deallocated by using axl_doc_free.

References axl_false, and axl_strdup().