[Axl] Printing contents of a node?

Francis Brosnan Blazquez francis at aspl.es
Tue Sep 11 08:59:38 CEST 2007


Hi Steven,

I see the issue. The function axl_node_get_content returns free text
enclosed by the node. In the function documentation there is a reference
to axl_node_is_empty. Check it. This also has to do with CHILDREN and
MIXED API. See [1] for more information.

For your case, if you are trying to print out the content of a
particular node, no matter if it has free text or mixed with more nodes
you can use: axl_node_dump. Taking your example it should look like:

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

Cheers!

[1] http://www.aspl.es/axl/html/axl_manual.html#two_apis

> Well i have tested 3 different xml files.
> 
> XML File #1
> 
> <metadata>
>     <name>axl</name>
> </metadata>
> 
> XML File #2
> 
> <?xml version="1.0" encoding="ISO-8859-1"?> 
> 
> <metadata>
>     <name>axl</name>
> </metadata>
> 
> And XML File #3 is attached to this email
> 
> What i was expecting the code to do is print out aether the name of
> the root node or the contents of the root node. But the code above
> prints nothing at all except a blank newline. 
> 
> Now im still learning c & xml  
> 
> But i think the problem is somewheres in this bit of code.
> 
>    node = axl_doc_get_root(doc);
>     value = axl_node_get_content(node, NULL); 
>     printf("%s \n", value); 
> 
> Because my code compiles and runs but prints a blank new line so
> i am assuming that the "value" variable is NULL and is there for
> printing 
> NULL(Nothing) to the screen. 
> 
> Thanks Steve 
-- 
Francis Brosnan Blazquez <francis at aspl.es>
Advanced Software Production Line, S.L.




More information about the Axl mailing list