<libroxml
version="3.0.2"
/>
|
XML content access module. More...
#include <string.h>
#include <stdlib.h>
#include "roxml_mem.h"
#include "roxml_file.h"
#include "roxml_buff.h"
Go to the source code of this file.
Data Structures | |
struct | roxml_escape_char |
Functions | |
ROXML_API int | roxml_escape (const char *buf, int decode, char *out) |
XML encoding/decoding function. | |
ROXML_STATIC ROXML_INT int | roxml_read (int pos, int size, char *buffer, node_t *node) |
read xml doc function | |
ROXML_STATIC ROXML_INT int | roxml_content_size (node_t *n, int *offset) |
ROXML_STATIC ROXML_INT char * | roxml_prepare_buffer (node_t *n, char *buffer, int contentsize, int size) |
ROXML_API char * | roxml_get_content (node_t *n, char *buffer, int bufsize, int *size) |
content getter function | |
ROXML_STATIC ROXML_INT int | roxml_name_size (node_t *n, int size, int *offset) |
ROXML_API char * | roxml_get_name (node_t *n, char *buffer, int size) |
name getter function | |
ROXML_API int | roxml_get_nodes_nb (node_t *n, int type) |
number of nodes getter function | |
ROXML_STATIC ROXML_INT node_t * | roxml_get_nodes_by_name (node_t *n, int type, char *name) |
ROXML_STATIC ROXML_INT node_t * | roxml_get_nodes_by_nth (node_t *n, int type, int nth) |
ROXML_API node_t * | roxml_get_nodes (node_t *n, int type, char *name, int nth) |
nodes getter function | |
ROXML_API node_t * | roxml_get_ns (node_t *n) |
namespace getter function | |
ROXML_API int | roxml_get_pi_nb (node_t *n) |
process-instruction number getter function | |
ROXML_API node_t * | roxml_get_pi (node_t *n, int nth) |
process-instruction getter function | |
ROXML_API int | roxml_get_cmt_nb (node_t *n) |
comments number getter function | |
ROXML_API node_t * | roxml_get_cmt (node_t *n, int nth) |
comment getter function | |
ROXML_API int | roxml_get_txt_nb (node_t *n) |
text node number getter function | |
ROXML_API node_t * | roxml_get_txt (node_t *n, int nth) |
text node getter function | |
ROXML_API int | roxml_get_attr_nb (node_t *n) |
number of attribute getter function | |
ROXML_API node_t * | roxml_get_attr (node_t *n, char *name, int nth) |
attribute getter function | |
ROXML_API int | roxml_get_chld_nb (node_t *n) |
chlds number getter function | |
ROXML_API node_t * | roxml_get_chld (node_t *n, char *name, int nth) |
chld getter function | |
ROXML_API int | roxml_get_type (node_t *n) |
node type function | |
ROXML_API int | roxml_get_node_position (node_t *n) |
node get position function | |
Variables | |
struct roxml_escape_char | specials [5] |
XML content access 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_content.c.
|
inline |
Definition at line 88 of file roxml_content.c.
roxml_escape | ( | const char * | buf, |
int | decode, | ||
char * | out | ||
) |
XML encoding/decoding function.
this function converts the escape codes into ascii char or special carachers in escape codes.
buf | the bytes to be converted |
decode | indicates whether to encde or decode escape caracteres. |
out | is filled with the encoded/decoded data if not null. |
Definition at line 31 of file roxml_content.c.
attribute getter function
This function get the nth attribute of a node.
n | is one node of the tree |
name | is the name of the attribute to get |
nth | the id of attribute to read |
example: given the following xml file
<xml> <product id="42" class="item"/> </xml>
Definition at line 444 of file roxml_content.c.
|
inline |
number of attribute getter function
This function returns the number of attributes for a given node
n | is one node of the tree |
Definition at line 439 of file roxml_content.c.
chld getter function
This function returns a given chld of a node etheir by name, or the nth child.
n | is one node of the tree |
name | is the name of the child to get |
nth | is the id of the chld to get |
example: given the following xml file
<xml> <item1/> <item2/> <item3/> </xml>
Definition at line 454 of file roxml_content.c.
|
inline |
chlds number getter function
This function return the number of chlidren for a given node
n | is one node of the tree |
Definition at line 449 of file roxml_content.c.
comment getter function
This function returns the nth comment of a node
n | is one node of the tree |
nth | is the id of the cmt to get |
example: given the following xml file
<xml> <item1/> <!--comment1--> <!--comment2--> <item2/> <item3/> </xml>
Definition at line 424 of file roxml_content.c.
|
inline |
comments number getter function
This function return the number of comments for a given node
n | is one node of the tree |
Definition at line 419 of file roxml_content.c.
char * roxml_get_content | ( | node_t * | n, |
char * | buffer, | ||
int | bufsize, | ||
int * | size | ||
) |
content getter function
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:
returned string should be freed using roxml_release when not used anymore
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 |
Definition at line 148 of file roxml_content.c.
char * roxml_get_name | ( | node_t * | n, |
char * | buffer, | ||
int | size | ||
) |
name getter function
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:
Be carreful as if your buffer is too short for the returned string, it will be truncated
n | is one node of the tree |
buffer | a buffer pointer or NULL if has to be auto allocated |
size | the size of buffer pointed by buffer if not NULL |
Definition at line 225 of file roxml_content.c.
roxml_get_node_position | ( | node_t * | n | ) |
node get position function
This function tells the index of a node between all its siblings homonyns.
n | is the node to test |
Definition at line 466 of file roxml_content.c.
char * roxml_get_nodes | ( | node_t * | n, |
int | type, | ||
char * | name, | ||
int | nth | ||
) |
nodes getter function
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.
n | is one node of the tree |
type | is the bitmask of node types we want to consider |
name | is the name of the child to get. This parameter is only relevant for node with types: ROXML_ELM_NODE, ROXML_ATTR_NODE, ROXML_PI_NODE |
nth | the id of attribute to read |
Definition at line 394 of file roxml_content.c.
|
inline |
Definition at line 336 of file roxml_content.c.
Definition at line 357 of file roxml_content.c.
int roxml_get_nodes_nb | ( | node_t * | n, |
int | type | ||
) |
number of nodes getter function
This function returns the number of nodes matching type flag contained in a given node all other roxml_get_*_nb are wrapper to this
n | is one node of the tree |
type | is the bitmask of node types we want to consider |
example: given the following xml file
<xml> <!-- comment --> <?value="2"?> <product id="42" class="item"/> <product id="43" class="item"/> </xml>
Definition at line 308 of file roxml_content.c.
namespace getter function
This function returns the namespace of a node
n | is one node of the tree |
example: given the following xml file
<xml xmlns:test="http://www.test.org"> <test:item1 test:value1="3"/> </xml>
Definition at line 404 of file roxml_content.c.
process-instruction getter function
This function returns the nth process-instruction of a node.
n | is one node of the tree |
nth | is the id of the pi to get |
example: given the following xml file
<xml> <item1/> <?test value="2"?> <?test param="3"?> <item2/> <item3/> </xml>
Definition at line 414 of file roxml_content.c.
|
inline |
process-instruction number getter function
This function return the number of process-instruction in a given node
n | is one node of the tree |
Definition at line 409 of file roxml_content.c.
|
inline |
text node getter function
this function return the text content of a node as a ROXML_TXT_NODE the content of the text node can be read using the roxml_get_content function
n | the node that contains text |
nth | the nth text node to retrieve |
example: given this xml file:
<xml> This is <item/> an example <item/> of text nodes </xml>
Definition at line 434 of file roxml_content.c.
|
inline |
text node number getter function
this function return the number of text nodes in a standard node
n | the node to search into |
Definition at line 429 of file roxml_content.c.
|
inline |
node type function
This function tells if a node is an ROXML_ATTR_NODE, ROXML_TXT_NODE, ROXML_PI_NODE, ROXML_CMT_NODE or ROXML_ELM_NODE. Warning: ROXML_CDATA_NODE are special. They return a type as ROXML_TXT_NODE.
n | is the node to test |
Definition at line 459 of file roxml_content.c.
|
inline |
Definition at line 200 of file roxml_content.c.
|
inline |
Definition at line 134 of file roxml_content.c.
|
inline |
read xml doc function
this function read inside a xml doc (file or buffer) and fill the given buffer
pos | the pos in the xml document |
size | the size of the data to read |
buffer | the destination buffer |
node | the node that belong to the tree we want to read to |
Definition at line 74 of file roxml_content.c.
struct roxml_escape_char specials[5] |
Definition at line 23 of file roxml_content.c.