[Axl] Printing contents of a node?

Steven Starr comtuxaps at gmail.com
Tue Sep 11 09:22:52 CEST 2007


Just to help out others here is the complete code that works.

 #include <axl.h>
 #include <stdio.h>

/*How to compile this code.*/
/* gcc parser.c -o parser -I/usr/include/axl  -laxl -lm */

 int main (int argc, char *argv[])
 {
    axlError **error;

    // top level definitions
    axlDoc *doc = NULL;
    axlNode *node = NULL;
    char *value;

    // initialize axl library
    if (! axl_init ()) {
        printf ("Unable to initialize Axl library\n");
          return -1;
    }

    // get current doc reference
    doc = axl_doc_parse_from_file ("test.xml", error);
    if (doc == NULL) {
        axl_error_free (*error);
        return false;
    }

    node = axl_doc_get_root(doc);
    axl_node_dump(node, &value, NULL);
    printf("%s \n", value);

    // release the document
    axl_doc_free (doc);
    axl_free (value);

    // cleanup axl library
    axl_end ();

    return true;
 }


Here is the xml file "test.xml"

<?xml version="1.0" encoding="ISO-8859-1"?>

<metadata>
    <name>axl</name>
</metadata>


Here is what the output looks like.

bash-3.2# ./parser
<metadata><name>axl</name></metadata>

And A Thank You To Francis For They Help :)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.aspl.es/pipermail/axl/attachments/20070911/c5dda675/attachment.htm 


More information about the Axl mailing list