axl main logo
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Modules Pages
void axl_node_set_child ( axlNode parent,
axlNode child 

Allows to configure a child node to the given parent.

This is a fundamental function while building xml document inside memory. The way the xml nodes are linked to conform the xml document structure relay on this function.

The idea is that every call to this function makes the child xml node to be placed at the end of the current item child set, that represents current child list for the provided parent.

One important question while using this function is that you must not reuse the same xml node reference, adding it several time to the same parent (or different parents). You must create a new xml node reference (axl_node_create) for every call you do to this function.

So, to build the following structure:

1 <document>
2  <child1 />
3  <child2 />
4 </document>

You must perform the following operations:

1 axlNode * parent;
2 axlNode * child;
4 // create the parent node
5 parent = axl_node_create ("document");
7 // create the first child
8 child = axl_node_create ("child1");
10 // set it to the parent
11 axl_node_set_child (parent, child);
13 // create the second child
14 child = axl_node_create ("child2");
16 // set it to the parent
17 axl_node_set_child (parent, child);

See also axl_node_set_child_after which could help you adding new nodes not using a parent node as a reference but a brother node.

parentThe parent node.
childThe child node. The child node must be a deep copy. Passing several references, pointing to the same value, will cause to seg fault the program at the time the parent child is deallocated.

References AXL_LEVEL_DEBUG, axl_return_if_fail, and ITEM_NODE.