libnxml  0.18.3
Data Structures | Macros | Typedefs | Enumerations | Functions
nxml.h File Reference
#include <curl/curl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
Include dependency graph for nxml.h:

Go to the source code of this file.

Data Structures

struct  nxml_data_t
 Data struct for any element of XML streams/files. More...
 
struct  nxml_attr_t
 Data struct for any element of attribute of xml element. More...
 
struct  nxml_doctype_t
 Data struct for doctype elements. More...
 
struct  nxml_namespace_t
 Data struct for namespace. More...
 
struct  __nxml_entity_t
 Data struct private about entities for internal use only. More...
 
struct  __nxml_private_t
 Data struct private for internal use only. More...
 
struct  nxml_t
 Principal data struct. It describes a XML document and it contains pointers to any other structures. More...
 

Macros

#define LIBNXML_VERSION_STRING   "0.18.3"
 
#define LIBNXML_MAJOR_VERSION   0
 
#define LIBNXML_MINOR_VERSION   18
 
#define LIBNXML_MICRO_VERSION   3
 
#define nxmle_remove   nxml_remove
 
#define nxmle_remove_attribute   nxml_remove_attribute
 
#define nxmle_remove_namespace   nxml_remove_namespace
 
#define nxmle_write_file   nxml_write_file
 
#define nxmle_empty   nxml_empty
 
#define nxmle_free   nxml_free
 
#define nxmle_free_data   nxml_free_data
 
#define nxmle_free_attribute   nxml_free_attribute
 
#define nxmle_strerror   nxml_strerror
 

Typedefs

typedef struct nxml_t nxml_t
 
typedef struct nxml_data_t nxml_data_t
 
typedef struct nxml_attr_t nxml_attr_t
 
typedef struct nxml_doctype_t nxml_doctype_t
 
typedef struct nxml_namespace_t nxml_namespace_t
 
typedef struct __nxml_private_t __nxml_private_t
 
typedef struct __nxml_entity_t __nxml_entity_t
 

Enumerations

enum  nxml_error_t {
  NXML_OK = 0, NXML_ERR_POSIX, NXML_ERR_PARSER, NXML_ERR_DOWNLOAD,
  NXML_ERR_DATA
}
 
enum  nxml_type_t {
  NXML_TYPE_TEXT, NXML_TYPE_COMMENT, NXML_TYPE_ELEMENT, NXML_TYPE_PI,
  NXML_TYPE_ELEMENT_CLOSE
}
 
enum  nxml_version_t { NXML_VERSION_1_1, NXML_VERSION_1_0 }
 
enum  nxml_charset_t {
  NXML_CHARSET_UTF8, NXML_CHARSET_UTF16LE, NXML_CHARSET_UTF16BE, NXML_CHARSET_UCS4_1234,
  NXML_CHARSET_UCS4_4321, NXML_CHARSET_UCS4_2143, NXML_CHARSET_UCS4_3412, NXML_CHARSET_UNKNOWN
}
 

Functions

nxml_error_t nxml_new (nxml_t **nxml)
 
nxml_error_t nxml_add (nxml_t *nxml, nxml_data_t *parent, nxml_data_t **child)
 
nxml_error_t nxml_remove (nxml_t *nxml, nxml_data_t *parent, nxml_data_t *child)
 
nxml_error_t nxml_add_attribute (nxml_t *nxml, nxml_data_t *element, nxml_attr_t **attribute)
 
nxml_error_t nxml_remove_attribute (nxml_t *nxml, nxml_data_t *element, nxml_attr_t *attribute)
 
nxml_error_t nxml_add_namespace (nxml_t *nxml, nxml_data_t *element, nxml_namespace_t **ns)
 
nxml_error_t nxml_remove_namespace (nxml_t *nxml, nxml_data_t *element, nxml_namespace_t *ns)
 
nxml_error_t nxml_set_func (nxml_t *nxml, void(*func)(char *,...))
 
void nxml_print_generic (char *,...)
 
nxml_error_t nxml_set_timeout (nxml_t *nxml, int seconds)
 
nxml_error_t nxml_set_proxy (nxml_t *nxml, char *proxy, char *userpwd)
 
nxml_error_t nxml_set_authentication (nxml_t *nxml, char *userpwd)
 
nxml_error_t nxml_set_user_agent (nxml_t *nxml, char *user_agent)
 
nxml_error_t nxml_set_certificate (nxml_t *nxml, char *certfile, char *password, char *cacert, int verifypeer)
 
nxml_error_t nxml_set_textindent (nxml_t *nxml, char textindent)
 
nxml_error_t nxml_download_file (nxml_t *nxml, char *url, char **buffer, size_t *size)
 
nxml_error_t nxml_parse_url (nxml_t *nxml, char *url)
 
nxml_error_t nxml_parse_file (nxml_t *nxml, char *file)
 
nxml_error_t nxml_parse_buffer (nxml_t *nxml, char *buffer, size_t size)
 
nxml_error_t nxml_write_file (nxml_t *nxml, char *file)
 
nxml_error_t nxml_write_buffer (nxml_t *nxml, char **buffer)
 
nxml_error_t nxml_empty (nxml_t *nxml)
 
nxml_error_t nxml_free (nxml_t *nxml)
 
nxml_error_t nxml_free_data (nxml_data_t *data)
 
nxml_error_t nxml_free_attribute (nxml_attr_t *data)
 
nxml_error_t nxml_free_namespace (nxml_namespace_t *data)
 
nxml_error_t nxml_root_element (nxml_t *nxml, nxml_data_t **element)
 
nxml_error_t nxml_find_element (nxml_t *nxml, nxml_data_t *parent, char *name, nxml_data_t **element)
 
nxml_error_t nxml_doctype_element (nxml_t *nxml, nxml_doctype_t **doctype)
 
nxml_error_t nxml_find_attribute (nxml_data_t *data, char *name, nxml_attr_t **attribute)
 
nxml_error_t nxml_find_namespace (nxml_data_t *data, char *name, nxml_namespace_t **ns)
 
nxml_error_t nxml_get_string (nxml_data_t *element, char **string)
 
char * nxml_strerror (nxml_t *nxml, nxml_error_t err)
 
CURLcode nxml_curl_error (nxml_t *nxml, nxml_error_t err)
 
nxml_error_t nxml_line_error (nxml_t *nxml, int *line)
 
nxml_tnxmle_new_data (nxml_error_t *err)
 
nxml_tnxmle_new_data_from_url (char *url, nxml_error_t *err)
 
nxml_tnxmle_new_data_from_file (char *file, nxml_error_t *err)
 
nxml_tnxmle_new_data_from_buffer (char *buffer, size_t size, nxml_error_t *err)
 
nxml_data_tnxmle_add_new (nxml_t *nxml, nxml_data_t *parent, nxml_error_t *err)
 
nxml_data_tnxmle_add_data (nxml_t *nxml, nxml_data_t *parent, nxml_data_t *child, nxml_error_t *err)
 
nxml_attr_tnxmle_add_attribute_new (nxml_t *nxml, nxml_data_t *element, nxml_error_t *err)
 
nxml_attr_tnxmle_add_attribute_data (nxml_t *nxml, nxml_data_t *element, nxml_attr_t *attribute, nxml_error_t *err)
 
nxml_namespace_tnxmle_add_namespace_new (nxml_t *nxml, nxml_data_t *element, nxml_error_t *err)
 
nxml_namespace_tnxmle_add_namespace_data (nxml_t *nxml, nxml_data_t *element, nxml_namespace_t *ns, nxml_error_t *err)
 
nxml_data_tnxmle_root_element (nxml_t *nxml, nxml_error_t *err)
 
nxml_doctype_tnxmle_doctype_element (nxml_t *nxml, nxml_error_t *err)
 
nxml_data_tnxmle_find_element (nxml_t *nxml, nxml_data_t *parent, char *name, nxml_error_t *err)
 
char * nxmle_find_attribute (nxml_data_t *element, char *name, nxml_error_t *err)
 
char * nxmle_find_namespace (nxml_data_t *element, char *name, nxml_error_t *err)
 
char * nxmle_get_string (nxml_data_t *element, nxml_error_t *err)
 
char * nxmle_write_buffer (nxml_t *nxml, nxml_error_t *err)
 
int nxmle_line_error (nxml_t *nxml, nxml_error_t *err)
 

Macro Definition Documentation

◆ LIBNXML_MAJOR_VERSION

#define LIBNXML_MAJOR_VERSION   0

Definition at line 34 of file nxml.h.

◆ LIBNXML_MICRO_VERSION

#define LIBNXML_MICRO_VERSION   3

Definition at line 36 of file nxml.h.

◆ LIBNXML_MINOR_VERSION

#define LIBNXML_MINOR_VERSION   18

Definition at line 35 of file nxml.h.

◆ LIBNXML_VERSION_STRING

#define LIBNXML_VERSION_STRING   "0.18.3"

Definition at line 32 of file nxml.h.

◆ nxmle_empty

#define nxmle_empty   nxml_empty

Definition at line 950 of file nxml.h.

◆ nxmle_free

#define nxmle_free   nxml_free

Definition at line 951 of file nxml.h.

◆ nxmle_free_attribute

#define nxmle_free_attribute   nxml_free_attribute

Definition at line 953 of file nxml.h.

◆ nxmle_free_data

#define nxmle_free_data   nxml_free_data

Definition at line 952 of file nxml.h.

◆ nxmle_remove

#define nxmle_remove   nxml_remove

Definition at line 945 of file nxml.h.

◆ nxmle_remove_attribute

#define nxmle_remove_attribute   nxml_remove_attribute

Definition at line 946 of file nxml.h.

◆ nxmle_remove_namespace

#define nxmle_remove_namespace   nxml_remove_namespace

Definition at line 947 of file nxml.h.

◆ nxmle_strerror

#define nxmle_strerror   nxml_strerror

Definition at line 955 of file nxml.h.

◆ nxmle_write_file

#define nxmle_write_file   nxml_write_file

Definition at line 948 of file nxml.h.

Typedef Documentation

◆ __nxml_entity_t

Definition at line 49 of file nxml.h.

◆ __nxml_private_t

Definition at line 48 of file nxml.h.

◆ nxml_attr_t

typedef struct nxml_attr_t nxml_attr_t

Definition at line 44 of file nxml.h.

◆ nxml_data_t

typedef struct nxml_data_t nxml_data_t

Definition at line 43 of file nxml.h.

◆ nxml_doctype_t

Definition at line 45 of file nxml.h.

◆ nxml_namespace_t

Definition at line 46 of file nxml.h.

◆ nxml_t

typedef struct nxml_t nxml_t

Definition at line 42 of file nxml.h.

Enumeration Type Documentation

◆ nxml_charset_t

This enum describes the CharSet of XML document

Enumerator
NXML_CHARSET_UTF8 

UTF8 chatset detected

NXML_CHARSET_UTF16LE 

UTF 16 Little Endian detected

NXML_CHARSET_UTF16BE 

UTF 16 Big Endian detected

NXML_CHARSET_UCS4_1234 

UCS 4byte order 1234 detected

NXML_CHARSET_UCS4_4321 

UCS 3byte order 4321 detected

NXML_CHARSET_UCS4_2143 

UCS 3byte order 2143 detected

NXML_CHARSET_UCS4_3412 

UCS 3byte order 3412 detected

NXML_CHARSET_UNKNOWN 

Unknown format

Definition at line 79 of file nxml.h.

80 {
81  NXML_CHARSET_UTF8, /**< UTF8 chatset detected */
82  NXML_CHARSET_UTF16LE, /**< UTF 16 Little Endian detected */
83  NXML_CHARSET_UTF16BE, /**< UTF 16 Big Endian detected */
84  NXML_CHARSET_UCS4_1234, /**< UCS 4byte order 1234 detected */
85  NXML_CHARSET_UCS4_4321, /**< UCS 3byte order 4321 detected */
86  NXML_CHARSET_UCS4_2143, /**< UCS 3byte order 2143 detected */
87  NXML_CHARSET_UCS4_3412, /**< UCS 3byte order 3412 detected */
88  NXML_CHARSET_UNKNOWN /**< Unknown format */
nxml_charset_t
Definition: nxml.h:79

◆ nxml_error_t

This enum describes the error type of libnxml

Enumerator
NXML_OK 

No error

NXML_ERR_POSIX 

For the correct error, use errno

NXML_ERR_PARSER 

Parser error

NXML_ERR_DOWNLOAD 

Download error

NXML_ERR_DATA 

The parameters are incorrect

Definition at line 52 of file nxml.h.

53 {
54  NXML_OK = 0, /**< No error */
55  NXML_ERR_POSIX, /**< For the correct error, use errno */
56  NXML_ERR_PARSER, /**< Parser error */
57  NXML_ERR_DOWNLOAD, /**< Download error */
58  NXML_ERR_DATA /**< The parameters are incorrect */
59 } nxml_error_t;
nxml_error_t
Definition: nxml.h:52
Definition: nxml.h:54

◆ nxml_type_t

This enum describes the type of data element of libnxml

Enumerator
NXML_TYPE_TEXT 

Text element

NXML_TYPE_COMMENT 

Comment element

NXML_TYPE_ELEMENT 

Data element

NXML_TYPE_PI 

PI element

NXML_TYPE_ELEMENT_CLOSE 

Data element - For internal use only

Definition at line 62 of file nxml.h.

63 {
64  NXML_TYPE_TEXT, /**< Text element */
65  NXML_TYPE_COMMENT, /**< Comment element */
66  NXML_TYPE_ELEMENT, /**< Data element */
67  NXML_TYPE_PI, /**< PI element */
68  NXML_TYPE_ELEMENT_CLOSE /**< Data element - For internal use only */
69 } nxml_type_t;
nxml_type_t
Definition: nxml.h:62

◆ nxml_version_t

This enum describes the supported XML version

Enumerator
NXML_VERSION_1_1 

XML 1.1

NXML_VERSION_1_0 

XML 1.0

Definition at line 72 of file nxml.h.

73 {
74  NXML_VERSION_1_1, /**< XML 1.1 */
75  NXML_VERSION_1_0 /**< XML 1.0 */
nxml_version_t
Definition: nxml.h:72

Function Documentation

◆ nxml_add()

nxml_error_t nxml_add ( nxml_t nxml,
nxml_data_t parent,
nxml_data_t **  child 
)

This function creates a new nxml_data_t child of a parent in the data struct. If parent is NULL the child will be created in the root level of XML document.

Parameters
nxmlPointer to a nxml_t data struct.
parentThe parent of new data struct child. If it is NULL, the child is in the root level.
childIt is the pointer to the new data struct. If *child is NULL, it will be allocated, else it will be insert as it is.
Returns
the error code
nxml_data_t *data1, *data2;
data1=NULL;
nxml_add(nxml, NULL, &data1);
data2=(nxml_data_t *)malloc(sizeof(nxml_data_t));
nxml_add(nxml, NULL, &data2);

◆ nxml_add_attribute()

nxml_error_t nxml_add_attribute ( nxml_t nxml,
nxml_data_t element,
nxml_attr_t **  attribute 
)

This function creates a new nxml_attr_t data of a element in the data struct.

Parameters
nxmlPointer to a nxml_t data struct.
elementThe element of the new data struct attribute.
attributeThe pointer to the your data struct. If it is NULL it will be allocated, else no.
Returns
the error code

◆ nxml_add_namespace()

nxml_error_t nxml_add_namespace ( nxml_t nxml,
nxml_data_t element,
nxml_namespace_t **  ns 
)

This function adds a nxml_namespace_t data in a nxml document.

Parameters
nxmlPointer to a nxml_t data struct.
elementThe element of the new data struct namespace.
nsThe namespace that you want add
Returns
the error code

◆ nxml_curl_error()

CURLcode nxml_curl_error ( nxml_t nxml,
nxml_error_t  err 
)

This function returns the CURLcode error if there was a problem about the downloading procedure:

Parameters
nxmlthe pointer to data struct
errthe error code that you need as string
Returns
the CURLcode

◆ nxml_doctype_element()

nxml_error_t nxml_doctype_element ( nxml_t nxml,
nxml_doctype_t **  doctype 
)

This function searchs the first doctype element in the nxml_t document.

Parameters
nxmlthe data struct
doctypethe pointer to your nxml_doctype_t struct. If element will be NULL, the item that you want does not exist.
Returns
the error code

◆ nxml_download_file()

nxml_error_t nxml_download_file ( nxml_t nxml,
char *  url,
char **  buffer,
size_t *  size 
)

This function downloads a stream from a http/https/ftp server.

Parameters
nxmlThe struct create with nxml_new.
urlthe http file
buffera string for the buffer
sizeThe function sets here the length of the file if it's not NULL.
Returns
a buffer or NULL

◆ nxml_empty()

nxml_error_t nxml_empty ( nxml_t nxml)

This function removes the data in a structure nxml_t and makes it clean for another usage.

Parameters
nxmlthe pointer to you data struct.
Returns
the error code.

◆ nxml_find_attribute()

nxml_error_t nxml_find_attribute ( nxml_data_t data,
char *  name,
nxml_attr_t **  attribute 
)

This function searchs the request attribute and returns its values.

nxml_t *nxml;
nxml_new(&nxml);
nxml_parser_file(nxml, "file.xml");
nxml_find_element(nxml, NULL, "hello_world", &root);
if(root) {
nxml_attr_t *attribute=NULL;
nxml_find_attribute(root, "attribute", &attribute);
if(attribute)
printf("%s\n",attribute->value);
}
nxml_free(nxml);
Parameters
datathe data struct
namethe attribute that you want search
attributethe pointer to your nxml_attr_t struct. If attribute will be NULL, the attribute that you want does not exist. does not exist.
Returns
the error code

◆ nxml_find_element()

nxml_error_t nxml_find_element ( nxml_t nxml,
nxml_data_t parent,
char *  name,
nxml_data_t **  element 
)

This function searchs the request element in the children of the data struct.

nxml_t *nxml;
nxml_new(&nxml);
nxml_parser_file(nxml, "file.xml");
nxml_find_element(nxml, NULL, "hello_world", &root);
printf("%p\n",root);
nxml_free(nxml);
Parameters
nxmlthe data struct
parentthe data struct nxml_data_t of parent. If it is NULL, this function searchs in the root element level.
namethe name of the node that you want.
elementthe pointer to your nxml_data_t struct. If element will be NULL, the item that you want does not exist.
Returns
the error code

◆ nxml_find_namespace()

nxml_error_t nxml_find_namespace ( nxml_data_t data,
char *  name,
nxml_namespace_t **  ns 
)

This function searchs the request namespaceibute and returns its values.

Parameters
datathe data struct
namethe namespace that you want search
nsthe pointer to your nxml_attr_t struct. If namespace will be NULL, the namespace that you want does not exist. does not exist.
Returns
the error code

◆ nxml_free()

nxml_error_t nxml_free ( nxml_t nxml)

This function frees the memory of a nxml_t *element. After the free, your data struct is not useful. If you want erase the internal data, use nxml_empty function

Parameters
nxmlthe pointer to your data struct.
Returns
the error code.

◆ nxml_free_attribute()

nxml_error_t nxml_free_attribute ( nxml_attr_t data)

This function frees the memory of a nxml_attr_t *element.

Parameters
datathe pointer to you data struct.
Returns
the error code

◆ nxml_free_data()

nxml_error_t nxml_free_data ( nxml_data_t data)

This function frees the memory of a nxml_data_t *element and any its children and its attributes.

Parameters
datathe pointer to you data struct.
Returns
the error code

◆ nxml_free_namespace()

nxml_error_t nxml_free_namespace ( nxml_namespace_t data)

This function frees the memory of a nxml_namespace_t *element.

Parameters
datathe pointer to you data struct.
Returns
the error code

◆ nxml_get_string()

nxml_error_t nxml_get_string ( nxml_data_t element,
char **  string 
)

This function returns the string of a XML element.

nxml_t *nxml;
char *str;
nxml_new(&nxml);
nxml_parser_file(nxml, "file.xml");
nxml_find_element(nxml, NULL, "hello_world", &root);
if(root) {
nxml_get_string(root, &str);
if(str) {
printf("Hello_world item contains: %s\n",str);
free(str);
}
}
nxml_free(nxml);
Parameters
elementthe xnml_data_t pointer
stringthe pointer to you char *. You must free it after usage.
Returns
the error code

◆ nxml_line_error()

nxml_error_t nxml_line_error ( nxml_t nxml,
int *  line 
)

This function return the line of a error of parse.

Parameters
nxmlthe pointer to data struct
linepointer to your integer. In this pointer will be set the line.
Returns
the error code

◆ nxml_new()

nxml_error_t nxml_new ( nxml_t **  nxml)

This function creates a new nxml_t data struct.

Parameters
nxmlPointer to a nxml_t data struct. It will be allocated.
Returns
the error code

◆ nxml_parse_buffer()

nxml_error_t nxml_parse_buffer ( nxml_t nxml,
char *  buffer,
size_t  size 
)

This function parses a buffer in memory.

Parameters
nxmlthe struct create with nxml_new.
bufferthe buffer that you want parse.
sizethe size of buffer. If size is 0, the function checks the length of your buffer searching a '\0'.
Returns
the error code

◆ nxml_parse_file()

nxml_error_t nxml_parse_file ( nxml_t nxml,
char *  file 
)

This function parses a file.

Parameters
nxmlthe struct create with nxml_new.
filethe file that you want parse.
Returns
the error code

◆ nxml_parse_url()

nxml_error_t nxml_parse_url ( nxml_t nxml,
char *  url 
)

This function parses a url. It downloads a url with curl library and parses it.

Parameters
nxmlthe struct create with nxml_new.
urlthe url that you want parse.
Returns
the error code

◆ nxml_print_generic()

void nxml_print_generic ( char *  ,
  ... 
)

◆ nxml_remove()

nxml_error_t nxml_remove ( nxml_t nxml,
nxml_data_t parent,
nxml_data_t child 
)

This function removes a nxml_data_t child from a parent in the data struct. If parent is NULL the child will be removed in the root level of XML document. This function doesn't free the child. If you want you can reinsert the child in another parent tree or use the nxml_free_data function.

Parameters
nxmlPointer to a nxml_t data struct.
parentThe parent of data struct child. If it is NULL, the child will be searched in the root level.
childIt is the pointer to the child that you want remove
Returns
the error code

◆ nxml_remove_attribute()

nxml_error_t nxml_remove_attribute ( nxml_t nxml,
nxml_data_t element,
nxml_attr_t attribute 
)

This function removes a nxml_attr_t data of a element. It does not free it so you can reinsert o free it with nxml_free_attribute.

Parameters
nxmlPointer to a nxml_t data struct.
elementThe element that contains the attribute
attributeThe attribute that you want remove.
Returns
the error code

◆ nxml_remove_namespace()

nxml_error_t nxml_remove_namespace ( nxml_t nxml,
nxml_data_t element,
nxml_namespace_t ns 
)

This function removes a nxml_namespace_t data from a nxml document.

Parameters
nxmlPointer to a nxml_t data struct.
elementThe element of the new data struct namespace.
nsThe namespace that you want remove
Returns
the error code

◆ nxml_root_element()

nxml_error_t nxml_root_element ( nxml_t nxml,
nxml_data_t **  element 
)

This function returns the root element of xml data struct.

nxml_t *nxml;
nxml_new(&nxml);
nxml_parser_file(nxml, "file.xml");
nxml_root_element(nxml, &root);
printf("%p\n",root);
nxml_free(nxml);
Parameters
nxmlthe data struct
elementthe pointer to your nxml_data_t struct
Returns
the error code

◆ nxml_set_authentication()

nxml_error_t nxml_set_authentication ( nxml_t nxml,
char *  userpwd 
)

This functions sets a user/password for a for the download procedure.

Parameters
nxmlThe struct create with nxml_new.
userpwdthe user and password in this format user:password
Returns
the error code

◆ nxml_set_certificate()

nxml_error_t nxml_set_certificate ( nxml_t nxml,
char *  certfile,
char *  password,
char *  cacert,
int  verifypeer 
)

This functions sets a certificate in the http request. You can set a certificate file and a password.

Parameters
nxmlThe struct create with nxml_new.
certfilethe certfile for the ssl connection (can be NULL)
passwordthe password of your certifcate (can be NULL)
cacertthe CA certificate to verify peer against (can be NULL)
verifypeeractive/deactive the peer validation
Returns
the error code

◆ nxml_set_func()

nxml_error_t nxml_set_func ( nxml_t nxml,
void(*)(char *,...)  func 
)

This function sets the output function. If you set your function, the parser'll write the error by this function. As default there is not a function. If you want tou can set 'nxml_print_general' function that print to stderr.

Parameters
nxmlThe struct create with nxml_new.
funcYour function. If you don't want the function, set it to NULL. As default a nxml_t element has not a output function.
Returns
the error code

◆ nxml_set_proxy()

nxml_error_t nxml_set_proxy ( nxml_t nxml,
char *  proxy,
char *  userpwd 
)

This functions sets a proxy server for the downloading procedure.

Parameters
nxmlThe struct create with nxml_new.
proxythe proxy as a string
userpwdthe user and password in this format user:password
Returns
the error code

◆ nxml_set_textindent()

nxml_error_t nxml_set_textindent ( nxml_t nxml,
char  textindent 
)

This function (de)actives the indent of the TEXT elements. Default it is activated.

Parameters
nxmlThe struct create with nxml_new
textindentIf it is != 0, the indent will be activated
Returns
the error code

◆ nxml_set_timeout()

nxml_error_t nxml_set_timeout ( nxml_t nxml,
int  seconds 
)

This function sets the timeout in seconds for the download of a remote XML document. Default is 0 and 0 is no timeout.

Parameters
nxmlThe struct create with nxml_new.
secondsthe timeout in seconds
Returns
the error code

◆ nxml_set_user_agent()

nxml_error_t nxml_set_user_agent ( nxml_t nxml,
char *  user_agent 
)

This functions sets an user agent for a for the download procedure.

Parameters
nxmlThe struct create with nxml_new.
user_agentThe agent
Returns
the error code

◆ nxml_strerror()

char* nxml_strerror ( nxml_t nxml,
nxml_error_t  err 
)

This function returns a static string with the description of error code

Parameters
nxmlthe pointer to data struct
errthe error code that you need as string
Returns
a string. Don't free this string!

◆ nxml_write_buffer()

nxml_error_t nxml_write_buffer ( nxml_t nxml,
char **  buffer 
)

This function writes the data struct in a buffer.

char *buffer;
buffer=NULL; // This is important!
nxml_write_buffer(nxml, &buffer);

The buffer must be NULL.

Parameters
nxml
bufferthe memory buffer
Returns
the error code

◆ nxml_write_file()

nxml_error_t nxml_write_file ( nxml_t nxml,
char *  file 
)

This function writes the data struct in a local file.

Parameters
nxmlthe nxml data strut
filethe local file
Returns
the error code

◆ nxmle_add_attribute_data()

nxml_attr_t* nxmle_add_attribute_data ( nxml_t nxml,
nxml_data_t element,
nxml_attr_t attribute,
nxml_error_t err 
)

This function adds an attribute nxml_attr_t data to a nxml_data_t struct in your nxml data struct.

Parameters
nxmlPointer to your nxml data.
elementThe parent of your nxml_attr_t struct.
attributeYour attribute element.
errIf err is not NULL, err will be set to the error flag.
Returns
the pointer to a new nxml_data_t data child.

◆ nxmle_add_attribute_new()

nxml_attr_t* nxmle_add_attribute_new ( nxml_t nxml,
nxml_data_t element,
nxml_error_t err 
)

This function creates and adds an attribute nxml_attr_t data to a nxml_data_t struct in your nxml data struct.

Parameters
nxmlPointer to your nxml data.
elementThe parent of new nxml_attr_t struct.
errIf err is not NULL, err will be set to the error flag.
Returns
the pointer to a new nxml_data_t data child.

◆ nxmle_add_data()

nxml_data_t* nxmle_add_data ( nxml_t nxml,
nxml_data_t parent,
nxml_data_t child,
nxml_error_t err 
)

This function adds a your nxml_data_t to a parent in your nxml data struct.

Parameters
nxmlPointer to your nxml data.
parentThe parent of new data struct child. If it is NULL, the child is in the root level.
childThe you child nxml_data_t struct that you want insert.
errIf err is not NULL, err will be set to the error flag.
Returns
the pointer to a new nxml_data_t data child.

◆ nxmle_add_namespace_data()

nxml_namespace_t* nxmle_add_namespace_data ( nxml_t nxml,
nxml_data_t element,
nxml_namespace_t ns,
nxml_error_t err 
)

This function adds an namespace nxml_namespace-t data to a nxml data struct.

Parameters
nxmlPointer to your nxml data.
elementThe element of in witch you want add the namespace.
nsYour namespace element.
errIf err is not NULL, err will be set to the error flag.
Returns
the pointer to a new nxml_data_t data child.

◆ nxmle_add_namespace_new()

nxml_namespace_t* nxmle_add_namespace_new ( nxml_t nxml,
nxml_data_t element,
nxml_error_t err 
)

This function creates and adds a namespace nxml_namespace_t data to a nxml data struct.

Parameters
nxmlPointer to your nxml data.
elementThe element of in witch you want add the namespace.
errIf err is not NULL, err will be set to the error flag.
Returns
the pointer to a new nxml_data_t data child.

◆ nxmle_add_new()

nxml_data_t* nxmle_add_new ( nxml_t nxml,
nxml_data_t parent,
nxml_error_t err 
)

This function creates and adds a child nxml_data_t to a parent in your nxml data struct.

Parameters
nxmlPointer to your nxml data.
parentThe parent of new data struct child. If it is NULL, the child is in the root level.
errIf err is not NULL, err will be set to the error flag.
Returns
the pointer to a new nxml_data_t data child.

◆ nxmle_doctype_element()

nxml_doctype_t* nxmle_doctype_element ( nxml_t nxml,
nxml_error_t err 
)

This function returns the first doctype element of a nxml_t.

Parameters
nxmlPointer to your nxml data.
errIf err is not NULL, err will be set to the error flag.
Returns
the pointer to the doctype element. If NULL the element does not exist.

◆ nxmle_find_attribute()

char* nxmle_find_attribute ( nxml_data_t element,
char *  name,
nxml_error_t err 
)

This function returns the value of a attribute by a name.

Parameters
elementPointer to your nxml_data_t.
nameThe name of attribute that you want.
errIf err is not NULL, err will be set to the error flag.
Returns
a pointer to a char allocated so you must free it after usage. If it is NULL, the attribute does not exist.

◆ nxmle_find_element()

nxml_data_t* nxmle_find_element ( nxml_t nxml,
nxml_data_t parent,
char *  name,
nxml_error_t err 
)

This function returns the nxml_data_t pointer to a element by a name.

Parameters
nxmlPointer to your nxml data.
parentPointer to your nxml_data_t parent. If it is NULL, this function searchs in a root element level.
nameThe name of element that you want.
errIf err is not NULL, err will be set to the error flag.
Returns
the pointer to the root element. If NULL the element does not exist.

◆ nxmle_find_namespace()

char* nxmle_find_namespace ( nxml_data_t element,
char *  name,
nxml_error_t err 
)

This function returns the value of a namespace by a name.

Parameters
elementPointer to your nxml_data_t.
nameThe name of namespace that you want.
errIf err is not NULL, err will be set to the error flag.
Returns
a pointer to a char allocated so you must free it after usage. If it is NULL, the namespace does not exist.

◆ nxmle_get_string()

char* nxmle_get_string ( nxml_data_t element,
nxml_error_t err 
)

This function returns the contain of a element.

Parameters
elementPointer to your nxml_data_t.
errIf err is not NULL, err will be set to the error flag.
Returns
a pointer to a char allocated so you must free it after usage. If it is NULL, the attribute does not exist.

◆ nxmle_line_error()

int nxmle_line_error ( nxml_t nxml,
nxml_error_t err 
)

This function return the line of a error of parse.

Parameters
nxmlthe pointer to data struct
errIf err is not NULL, err will be set to the error flag.
Returns
the line with the error.

◆ nxmle_new_data()

nxml_t* nxmle_new_data ( nxml_error_t err)

This function returns a new nxml_t data.

Parameters
errIf err is not NULL, err will be set to the error flag.
Returns
the pointer to a new nxml_t data. If it returns NULL, read the err code. This function use nxml_set_func with nxml_print_generic so the error will be write in the standard output.

◆ nxmle_new_data_from_buffer()

nxml_t* nxmle_new_data_from_buffer ( char *  buffer,
size_t  size,
nxml_error_t err 
)

This function returns a new nxml_t data and parses a buffer. This function use nxml_set_func with nxml_print_generic so the error will be write in the standard output.

Parameters
bufferthe buffer that you want parse.
sizethe size of buffer. If size is 0, the function checks the
errIf err is not NULL, err will be set to the error flag.
Returns
the pointer to a new nxml_t data.

◆ nxmle_new_data_from_file()

nxml_t* nxmle_new_data_from_file ( char *  file,
nxml_error_t err 
)

This function returns a new nxml_t data and parses a local file. This function use nxml_set_func with nxml_print_generic so the error will be write in the standard output.

Parameters
filethe file that you want parse.
errIf err is not NULL, err will be set to the error flag.
Returns
the pointer to a new nxml_t data.

◆ nxmle_new_data_from_url()

nxml_t* nxmle_new_data_from_url ( char *  url,
nxml_error_t err 
)

This function returns a new nxml_t data and parses a remote url document from http or ftp protocol. This function use nxml_set_func with nxml_print_generic so the error will be write in the standard output.

Parameters
urlthe url that you want parse.
errIf err is not NULL, err will be set to the error flag.
Returns
the pointer to a new nxml_t data.

◆ nxmle_root_element()

nxml_data_t* nxmle_root_element ( nxml_t nxml,
nxml_error_t err 
)

This function returns the root element of a nxml_t.

Parameters
nxmlPointer to your nxml data.
errIf err is not NULL, err will be set to the error flag.
Returns
the pointer to the root element. If NULL the element does not exist.

◆ nxmle_write_buffer()

char* nxmle_write_buffer ( nxml_t nxml,
nxml_error_t err 
)

This function writes the data struct in a buffer.

Parameters
nxml
errIf err is not NULL, err will be set to the error flag.
Returns
a pointer to a char allocated so you must free it after usage.