Function Documentation

this function add a new node to the tree. This will not update de buffer or file, only the RAM loaded tree. One should call roxml_commit_changes to save modifications. If the parent node is an ROXML_ELM_NODE, then, new node will be added as a child. Else the node will be added as a sibling of the parent node. In the later case, position parameter describes the position in the sibling list, instead of position in the children list.

Parameters

parent

the parent node

position

the position as a child of parent 1 is the first child, 0 for auto position at the end of children list...

this function syncs changes from the RAM tree to the given buffer in human or one-line format The tree will be processed starting with the root node 'n' and following with all its children or if n is the root, all its siblings and children. The tree will be dumped to a buffer if 'buffer' is not null. the buffer is allocated by the library and a pointer to it will be stored into 'buffer'. The allocated buffer can be freed using free()

Parameters

n

the root node of the tree to write

buffer

the address of a buffer where the tree will be written. This buffer have to be freed after use

this function sync changes from the RAM tree to the given buffer or file in human or one-line format The tree will be processed starting with the root node 'n' and following with all its children or if n is the root, all its siblings and children. The tree will be dumped to a file if 'dest' is not null and contains a valid path. The tree will be dumped to a buffer if 'buffer' is not null. the buffer is allocated by the library and a pointer to it will be stored into 'buffer'. The allocated buffer can be freed usinf free()

Warning

in the case of a tree loaded using roxml_load_doc, the roxml_commit_changes cannot be done to that same file since it may override datas it need. This usually result in a new file filled with garbages. The solution is to write it to a temporary file and rename it after roxml_close the current tree.

This function is now deprecated and one should use roxml_commit_buffer or roxml_commit_file that achieves the exact same goal.

Parameters

n

the root node of the tree to write

dest

the path to a file to write tree to

buffer

the address of a buffer where the tree will be written. This buffer have to be freed after use

this function synchronizes changes from the RAM tree to the given file in human or one-line format. The tree will be processed starting with the root node 'n' and following with all its children or if n is the root, all its siblings and children. The tree will be dumped to a file if fd is a valid file descriptor.

Warning

in the case of a tree loaded using roxml_load_doc, the roxml_commit_fd cannot be done to that same file since it may override datas it needs. This usually results in a new file filled with garbage. The solution is to write it to a temporary file and rename it after roxml_close the current tree.

Parameters

n

the root node of the tree to write

fd

the file descriptor to write tree to

human

0 for one-line tree, or 1 for human format (using tabs, newlines...)

Returns

the number of bytes written to file

The file described by fd is not truncated so this function allows one to append an XML subtree to an existing file.

this function sync changes from the RAM tree to the given file in human or one-line format The tree will be processed starting with the root node 'n' and following with all its children or if n is the root, all its siblings and children. The tree will be dumped to a file if 'dest' is not null and contains a valid path.

Warning

in the case of a tree loaded using roxml_load_doc, the roxml_commit_file cannot be done to that same file since it may override datas it needs. This usually resultis in a new file filled with garbage. The solution is to write it to a temporary file and rename it after roxml_close the current tree.

This function returns the content of a node.; if the returned pointer is NULL then the node either has no content or this function is irrelevant for this kind of node. depending on node type it will return:

ROXML_ELM_NODE: returns the concatenation of all direct text node children

ROXML_ATTR_NODE: returns the attribute value

ROXML_PI_NODE: returns the process-instruction instruction

ROXML_TXT_NODE: returns the text content of the node

ROXML_CMT_NODE: returns the text content of the comment

ROXML_NS_NODE: returns the namespace definition (usually an URL)

returned string should be freed using roxml_release when not used anymore

Parameters

n

is one node of the tree

buffer

is the buffer where result will be written or NULL for internal allocation

bufsize

the size if using custom buffer

size

the actual size of copied result. returned size should be less that buffer size since roxml_get_content will add the \0. if buffer was not NULL and size == buf_size, then given buffer was too small and node content was truncated

This function return the name of the node or fill the current buffer with it if not NULL. if name is NULL, the function will allocate a buffer that user should free using roxml_release when no longer needed. depending on node type it will return:

This function get the nth node matching type contained in a node, or the first node named name. All other roxml_get_* are wrapper to this function. When asking for several node type (let say ROXML_ALL_NODES), all ROXML_ATTR_NODE will be placed first, then, all other nodes will come mixed, depending on xml document order.

This function load a document by parsing all the corresponding nodes. The document must be contained inside the char * buffer given in parameter and remain valid until the roxml_close() function is called

Parameters

buffer

the XML buffer to load

Returns

the root node or ROXML_INVALID_DOC (NULL). errno is set to EINVAL in case of parsing error