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;
4 
5 // dump content variables
6 char * content;
7 int content_size;
8 
9 // create the document
10 doc = axl_doc_create (NULL, NULL, axl_true);
11 
12 // create the root document node
13 node = axl_node_create ("root-node");
14 
15 // configure it as the root
16 axl_doc_set_root (doc, node);
17 
18 // dump pretty
19 axl_doc_dump_pretty (doc, &content, &content_size, 4);
20 
21 // print the content and free
22 printf ("document size=%d, content: %s\n", content_size, content);
23 axl_free (content);
Parameters
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
Returns a newly allocated axlDoc instance that must be deallocated by using axl_doc_free.

References axl_false, and axl_strdup().