bool axl_doc_iterate ( axlDoc doc,
AxlIterationMode  mode,
axlIterationFunc  func,
axlPointer  ptr 
)

Allows to perform an iteration over the documented provided, visiting all nodes inside it.

The function allows to configure the iteration module using AxlIterationMode (mode variable) and providing a callback function that will be called for each node found (axlIterationFunc).

The function, optionall, allows to provide a user pointer that will be passed to the callback function. See documentation for the callback and the iteration module for more details.

Here is an example:

 void perform_iteration (axlDoc * doc)
 {
     // call to iterate
     axl_doc_iterate (doc, 
                      // visit childs before brothers
                      DEEP_ITERATION, 
                      // the func to execute: see below
                      show_node_found, 
                      // optional user pointer
                      NULL);
 }

 bool show_node_found (axlNode * node, axlNode * parent,
                       axlDoc  * doc, bool * was_removed, 
                       axlPointer ptr)
 {
      // Show node found 
      printf ("Node found: %s\n", axl_node_get_name (node));

      // If the node is removed inside the iteration
      // using axl_node_remove or axl_node_replace, you
      // must notify the iteration system using was_removed
      // as follow: (* was_removed) = true;
      //
      // If you don't remove anything, you don't need to do
      // anything especial with was_removed.

      // don't stop iteration
      return true;
 }

See also alternative APIs:

Parameters:
doc The xml document that will be iterated.
mode The iterarion type to be performed.
func The function to be called for each node found.
ptr An user defined pointer that will be passed to the callback function.
Returns:
The function returns true if the iteration was performed over all nodes or false it it was stoped by the iteration function (by returning false to stop the iteration). The function also false if the parameters provided doc or func are not defined.