<libroxml
version="3.0.2"
/>
|
XML document edition module. More...
Go to the source code of this file.
Functions | |
ROXML_STATIC ROXML_INT node_t * | roxml_get_real_prev_sibling (node_t *n) |
get real sibling | |
ROXML_STATIC ROXML_INT void | roxml_reset_ns (node_t *n, node_t *ns) |
internal function | |
ROXML_STATIC ROXML_INT void | roxml_del_std_node (node_t *n) |
node deletion function | |
ROXML_STATIC ROXML_INT void | roxml_del_txt_node (node_t *n) |
text node deletion function | |
ROXML_STATIC ROXML_INT void | roxml_del_arg_node (node_t *n) |
attribute node deletion function | |
ROXML_STATIC ROXML_INT node_t * | roxml_prepend_node (node_t *parent, node_t *n) |
ROXML_STATIC ROXML_INT node_t * | roxml_parent_node (node_t *parent, node_t *n, int position) |
node relocate function | |
ROXML_API void | roxml_del_node (node_t *n) |
node deletion function | |
ROXML_STATIC ROXML_INT void | roxml_generate_cmt_node (node_t *n, char *content) |
ROXML_STATIC ROXML_INT void | roxml_generate_txt_node (node_t *n, char *content) |
ROXML_STATIC ROXML_INT void | roxml_generate_elm_node (node_t *n, char *name, char *content) |
ROXML_STATIC ROXML_INT void | roxml_generate_pi_node (node_t *n, char *name, char *content) |
ROXML_STATIC ROXML_INT void | roxml_generate_attr_node (node_t *n, int type, char *name, char *content) |
ROXML_INT int | roxml_add_node_check (node_t *parent, int type, char *name, char *content) |
ROXML_API node_t * | roxml_add_node (node_t *parent, int position, int type, char *name, char *content) |
add a node to the tree | |
ROXML_API node_t * | roxml_set_ns (node_t *n, node_t *ns) |
namespace setter function | |
XML document edition module.
(C) Copyright 2014 Tristan Lelong trist.nosp@m.an.l.nosp@m.elong.nosp@m.@lib.nosp@m.roxml.nosp@m..net
SPDX-Licence-Identifier: LGPL-2.1+ The author added a static linking exception, see License.txt.
Definition in file roxml_edit.c.
roxml_add_node | ( | node_t * | parent, |
int | position, | ||
int | type, | ||
char * | name, | ||
char * | value | ||
) |
add a node to the tree
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.
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... |
type | the type of node between ROXML_ATTR_NODE, ROXML_ELM_NODE, ROXML_TXT_NODE, ROXML_CDATA_NODE, ROXML_PI_NODE, ROXML_CMT_NODE, ROXML_NSDEF_NODE, ROXML_NS_NODE. |
name | the name of the node (mandatory for ROXML_ATTR_NODE and ROXML_ELM_NODE and ROXML_PI_NODE and ROXML_NSDEF_NODE and ROXML_NS_NODE only) |
value | the text content (mandatory for ROXML_TXT_NODE, ROXML_CDATA_NODE, ROXML_CMT_NODE, ROXML_ATTR_NODE and ROXML_NSDEF_NODE optional for ROXML_ELM_NODE, ROXML_PI_NODE). The text content for an attribute is the attribute value |
Escaping the as per XML specifications can be done by adding the ROXML_ESCAPED_MOD modifier to node type as showed below:
This will create a node that exports as:
* <node1>content <that> needs escaping</node1> *
paramaters name and value depending on node type:
some examples to obtain this xml result file
<root> <!-- sample XML file --> <item id="42"> <price> 24 </price> </item> </root>
Or also:
If you need a valid XML doc, just start by adding a corresponding process-instruction. Example, to obtain this xml file:
<?xml version="1.0" encoding="UTF-8"?> <!--sample file--> <doc> basic content <item/> <item/> <item/> </doc>
Definition at line 353 of file roxml_edit.c.
ROXML_INT int roxml_add_node_check | ( | node_t * | parent, |
int | type, | ||
char * | name, | ||
char * | content | ||
) |
Definition at line 313 of file roxml_edit.c.
roxml_del_arg_node | ( | node_t * | n | ) |
attribute node deletion function
this function delete an attribute node
n | the node to delete |
Definition at line 127 of file roxml_edit.c.
roxml_del_node | ( | node_t * | n | ) |
node deletion function
this function delete a node from the tree. The node is not really deleted from the file or buffer until the roxml_commit_changes is called, but it won't be visible anymore in the XML tree.
n | the node to delete |
Definition at line 204 of file roxml_edit.c.
roxml_del_std_node | ( | node_t * | n | ) |
node deletion function
this function delete a standard node
n | the node to delete |
Definition at line 85 of file roxml_edit.c.
roxml_del_txt_node | ( | node_t * | n | ) |
text node deletion function
this function delete a text node
n | the node to delete |
Definition at line 110 of file roxml_edit.c.
ROXML_STATIC ROXML_INT void roxml_generate_attr_node | ( | node_t * | n, |
int | type, | ||
char * | name, | ||
char * | content | ||
) |
Definition at line 281 of file roxml_edit.c.
ROXML_STATIC ROXML_INT void roxml_generate_cmt_node | ( | node_t * | n, |
char * | content | ||
) |
Definition at line 220 of file roxml_edit.c.
ROXML_STATIC ROXML_INT void roxml_generate_elm_node | ( | node_t * | n, |
char * | name, | ||
char * | content | ||
) |
Definition at line 238 of file roxml_edit.c.
ROXML_STATIC ROXML_INT void roxml_generate_pi_node | ( | node_t * | n, |
char * | name, | ||
char * | content | ||
) |
Definition at line 262 of file roxml_edit.c.
ROXML_STATIC ROXML_INT void roxml_generate_txt_node | ( | node_t * | n, |
char * | content | ||
) |
Definition at line 229 of file roxml_edit.c.
get real sibling
This function returns the real previous sibling of a node no matter what its type is.
n | is one node of the tree |
Definition at line 26 of file roxml_edit.c.
node relocate function
this function change the position of a node in its parent list
parent | the parent node |
n | the node to parent |
position | the position, 0 means or > nb children means at the end |
Definition at line 165 of file roxml_edit.c.
Definition at line 144 of file roxml_edit.c.
internal function
This function remove the namespace of a node if it is the one specified as argument, and replace it with its parent one
n | is one node of the tree |
ns | is one nsdef of the tree |
Definition at line 48 of file roxml_edit.c.
namespace setter function
This function set the namespace of a node to the given namespace definition. The namespace must be previously defined in the xml tree in an ancestor of node n.
n | is one node of the tree |
ns | is one nsdef node of the tree |
Definition at line 395 of file roxml_edit.c.