📄 nxml.h
字号:
nxml_doctype_t **doctype);*//** * This function searchs the request attribute and returns its values. * \code * nxml_t *nxml; * nxml_data_t *root; * * nxml_new(&nxml); * nxml_parser_file(nxml, "file.xml"); * nxml_find_element(nxml, NULL, "hello_world", &root); * if(root) { * char *str; * nxml_find_attribute(root, "attribute", &str); * printf("%s\n",attribute); * free(str); * } * nxml_free(nxml); * \endcode * * \param data the data struct * \param name the attribute that you want search * \param attribute the pointer to your nxml_attr_t struct. If attribute will * be NULL, the attribute that you want does not exist. * does not exist. * \return the error code */nxml_error_t nxml_find_attribute (nxml_data_t *data, char *name, nxml_attr_t **attribute);/** * This function searchs the request namespaceibute and returns its values. * * \param data the data struct * \param name the namespace that you want search * \param ns the pointer to your nxml_attr_t struct. If namespace will * be NULL, the namespace that you want does not exist. * does not exist. * \return the error code */nxml_error_t nxml_find_namespace (nxml_data_t *data, char *name, nxml_namespace_t **ns);/** * This function returns the string of a XML element. * \code * nxml_t *nxml; * nxml_data_t *root; * 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); * \endcode * * \param element the xnml_data_t pointer * \param string the pointer to you char *. You must free it after usage. * \return the error code *//*nxml_error_t nxml_get_string (nxml_data_t *element, char **string);*//* ERROR FUNCTIONS **********************************************************//** * This function returns a static string with the description of error code * \param err the error code that you need as string * \return a string. Don't free this string! */char * nxml_strerror (nxml_error_t err);/** * This function return the line of a error of parse. * \param nxml the pointer to data struct * \param line pointer to your integer. In this pointer will be set the line. * \return the error code *//*nxml_error_t nxml_line_error (nxml_t * nxml, int *line);*//* EASY FUNCTIONS ***********************************************************//** * This function returns a new nxml_t data. * * \param err If err is not NULL, err will be set to the error flag. * \return 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. *///nxml_t * nxmle_new_data (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. * * * \param url the url that you want parse. * \param err If err is not NULL, err will be set to the error flag. * \return the pointer to a new nxml_t data. *//****************************************************************nxml_t * nxmle_new_data_from_url (char *url, 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. * * \param file the file that you want parse. * \param err If err is not NULL, err will be set to the error flag. * \return the pointer to a new nxml_t data. *//*nxml_t * nxmle_new_data_from_file (char *file, 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. * * \param buffer the buffer that you want parse. * \param size the size of buffer. If size is 0, the function checks the * \param err If err is not NULL, err will be set to the error flag. * \return the pointer to a new nxml_t data. *//*nxml_t * nxmle_new_data_from_buffer (char *buffer, size_t size, nxml_error_t *err);*//** * This function creates and adds a child nxml_data_t to a parent in your * nxml data struct. * * \param nxml Pointer to your nxml data. * \param parent The parent of new data struct child. If it is NULL, the * child is in the root level. * \param err If err is not NULL, err will be set to the error flag. * \return the pointer to a new nxml_data_t data child. *//*nxml_data_t * nxmle_add_new (nxml_t * nxml, nxml_data_t *parent, nxml_error_t *err);*//** * This function adds a your nxml_data_t to a parent in your nxml * data struct. * * \param nxml Pointer to your nxml data. * \param parent The parent of new data struct child. If it is NULL, the * child is in the root level. * \param child The you child nxml_data_t struct that you want insert. * \param err If err is not NULL, err will be set to the error flag. * \return the pointer to a new nxml_data_t data child. *//*nxml_data_t * nxmle_add_data (nxml_t * nxml, nxml_data_t *parent, nxml_data_t *child, 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. * * \param nxml Pointer to your nxml data. * \param element The parent of new nxml_attr_t struct. * \param err If err is not NULL, err will be set to the error flag. * \return the pointer to a new nxml_data_t data child. *//*nxml_attr_t * nxmle_add_attribute_new (nxml_t *nxml, nxml_data_t *element, nxml_error_t *err);*//** * This function adds an attribute nxml_attr_t data to a * nxml_data_t struct in your nxml data struct. * * \param nxml Pointer to your nxml data. * \param element The parent of your nxml_attr_t struct. * \param attribute Your attribute element. * \param err If err is not NULL, err will be set to the error flag. * \return the pointer to a new nxml_data_t data child. *//*nxml_attr_t * nxmle_add_attribute_data (nxml_t *nxml, nxml_data_t *element, nxml_attr_t *attribute, nxml_error_t *err);*//** * This function creates and adds a namespace nxml_namespace_t data to a * nxml data struct. * * \param nxml Pointer to your nxml data. * \param element The element of in witch you want add the namespace. * \param err If err is not NULL, err will be set to the error flag. * \return the pointer to a new nxml_data_t data child. *//*nxml_namespace_t * nxmle_add_namespace_new (nxml_t *nxml, nxml_data_t *element, nxml_error_t *err);*//** * This function adds an namespace nxml_namespace-t data to a nxml data struct. * * \param nxml Pointer to your nxml data. * \param element The element of in witch you want add the namespace. * \param ns Your namespace element. * \param err If err is not NULL, err will be set to the error flag. * \return the pointer to a new nxml_data_t data child. *//*nxml_namespace_t * nxmle_add_namespace_data (nxml_t *nxml, nxml_data_t *element, nxml_namespace_t *ns, nxml_error_t *err);*//** * This function returns the root element of a nxml_t. * * \param nxml Pointer to your nxml data. * \param err If err is not NULL, err will be set to the error flag. * \return the pointer to the root element. If NULL the element does not * exist. */nxml_data_t * nxmle_root_element (nxml_t *nxml, nxml_error_t *err);/** * This function returns the first doctype element of a nxml_t. * * \param nxml Pointer to your nxml data. * \param err If err is not NULL, err will be set to the error flag. * \return the pointer to the doctype element. If NULL the element does not * exist. *//*nxml_doctype_t *nxmle_doctype_element (nxml_t *nxml, nxml_error_t *err);*//** * This function returns the nxml_data_t pointer to a element by * a name. * * \param nxml Pointer to your nxml data. * \param parent Pointer to your nxml_data_t parent. If it is NULL, this * function searchs in a root element level. * \param name The name of element that you want. * \param err If err is not NULL, err will be set to the error flag. * \return the pointer to the root element. If NULL the element does not * exist. *//*nxml_data_t * nxmle_find_element (nxml_t *nxml, nxml_data_t *parent, char *name, nxml_error_t *err);*//** * This function returns the value of a attribute by a name. * * \param element Pointer to your nxml_data_t. * \param name The name of attribute that you want. * \param err If err is not NULL, err will be set to the error flag. * \return a pointer to a char allocated so you must free it after usage. If * it is NULL, the attribute does not exist. */char * nxmle_find_attribute (nxml_data_t *element, char *name, nxml_error_t *err);/** * This function returns the value of a namespace by a name. * * \param element Pointer to your nxml_data_t. * \param name The name of namespace that you want. * \param err If err is not NULL, err will be set to the error flag. * \return a pointer to a char allocated so you must free it after usage. If * it is NULL, the namespace does not exist. *//*char * nxmle_find_namespace (nxml_data_t *element, char *name, nxml_error_t *err);*//** * This function returns the contain of a element. * * \param element Pointer to your nxml_data_t. * \param err If err is not NULL, err will be set to the error flag. * \return a pointer to a char allocated so you must free it after usage. If * it is NULL, the attribute does not exist. *//*char * nxmle_get_string (nxml_data_t *element, nxml_error_t *err);*//** * This function writes the data struct in a buffer. * * \param nxml * \param err If err is not NULL, err will be set to the error flag. * \return a pointer to a char allocated so you must free it after usage. *//*char * nxmle_write_buffer (nxml_t *nxml, nxml_error_t *err);*//** * This function return the line of a error of parse. * \param nxml the pointer to data struct * \param err If err is not NULL, err will be set to the error flag. * \return the line with the error. *///int nxmle_line_error (nxml_t * nxml, nxml_error_t *err);/* Easy functions defined: *///#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#ifdef __cplusplus}#endif#endif/* EOF */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -