src/ccpp_xml.c File Reference
Routines and functions for processing a XML file. This is a very thin layer around libxml2.
More...
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <err.h>
#include <sysexits.h>
#include <libxml/parser.h>
#include <libxml/tree.h>
#include "ccpp_xml.h"
Functions/Subroutines |
|
|
int | ccpp_xml_load (const char *filename, void **xml, void **root) |
int | ccpp_xml_unload (void **xml) |
int | ccpp_xml_ele_find (void **node, const char *name, void **ele) |
int | ccpp_xml_ele_next (void **node, const char *name, void **ele) |
int | ccpp_xml_ele_count (void **node, const char *name, int *n) |
int | ccpp_xml_ele_contents (void **node, char **value) |
int | ccpp_xml_ele_att (void **node, const char *name, char **value) |
Detailed Description
Routines and functions for processing a XML file. This is a very thin layer around libxml2.
Function Documentation
int ccpp_xml_ele_att |
( |
void ** |
node, |
|
|
const char * |
name, |
|
|
char ** |
value | |
|
) |
| | |
Get the attribute at the node.
- Parameters:
-
[in] | node | The toplevel node pointer to start from. |
[in] | name | The name of the attribute to get. |
[out] | value | The value of the attribute. |
- Return values:
-
| 0 | If it was sucessful. |
| 1 | If there was an error. |
< String length
< XML tree node
< The attribute value
int ccpp_xml_ele_contents |
( |
void ** |
node, |
|
|
char ** |
value | |
|
) |
| | |
Get the contents of a node.
- Parameters:
-
[in] | node | The toplevel node pointer to start from. |
[out] | value | The value of the attribute. |
- Return values:
-
| 0 | If it was sucessful. |
| 1 | If there was an error. |
< String length
< XML tree node
< The contents value
int ccpp_xml_ele_count |
( |
void ** |
node, |
|
|
const char * |
name, |
|
|
int * |
n | |
|
) |
| | |
Count the number of elements within the XML node.
- Parameters:
-
[in] | node | The toplevel node pointer to start from. |
[in] | name | The name element to count. |
[out] | n | The number of times the element was found. |
- Return values:
-
| 0 | If it was sucessful. |
| 1 | If there was an error. |
< XML tree root node
int ccpp_xml_ele_find |
( |
void ** |
node, |
|
|
const char * |
name, |
|
|
void ** |
ele | |
|
) |
| | |
Get the first occurance of the node.
- Parameters:
-
[in] | node | The toplevel node pointer to start from. |
[in] | name | The name element to retrieve. |
[out] | ele | The first occurance of the element. |
- Return values:
-
| 0 | If it was sucessful. |
| 1 | If there was an error. |
< XML tree root node
int ccpp_xml_ele_next |
( |
void ** |
node, |
|
|
const char * |
name, |
|
|
void ** |
ele | |
|
) |
| | |
Get the next occurance of the node.
This uses xmlNextElementSibling() followed by a check of the name.
- Parameters:
-
[in] | node | The toplevel node pointer to start from. |
[in] | name | The name element to retrieve. |
[out] | ele | The next occurance of the element. |
- Return values:
-
| 0 | If it was sucessful. |
| 1 | If there was an error. |
< XML tree root node
int ccpp_xml_load |
( |
const char * |
filename, |
|
|
void ** |
xml, |
|
|
void ** |
root | |
|
) |
| | |
Read a xml file and load the information.
- Parameters:
-
[in] | filename | The xml file name. |
[out] | xml | The xml document pointer. |
[out] | root | The root node of the xml document. |
- Return values:
-
| 0 | If it was sucessful. |
| 1 | If there was an error. |
int ccpp_xml_unload |
( |
void ** |
xml |
) |
|
Unload the XML document and clean-up the XML parser.
- Parameters:
-
[in] | xml | The xml document pointer. |
- Return values:
-
| 0 | If it was sucessful. |
| 1 | If there was an error. |
< XML document tree