cdata works
This commit is contained in:
parent
54806705c5
commit
1113b2dbe3
7 changed files with 196 additions and 126 deletions
18
example.c
18
example.c
|
|
@ -2,17 +2,17 @@
|
|||
|
||||
#define INDENT 2
|
||||
|
||||
void recursive(xmllib_node_t* node, int indent) {
|
||||
int i;
|
||||
xmllib_node_t* n;
|
||||
void recursive(xl_node_t* node, int indent) {
|
||||
int i;
|
||||
xl_node_t* n;
|
||||
for(i = 0; i < indent; i++) printf(" ");
|
||||
if(node->name != NULL && node->type == XMLLIB_NODE_NODE) {
|
||||
if(node->name != NULL && node->type == XL_NODE_NODE) {
|
||||
printf("<%s>\n", node->name);
|
||||
if(node->text != NULL) {
|
||||
for(i = 0; i < indent + INDENT; i++) printf(" ");
|
||||
printf("%s\n", node->text);
|
||||
}
|
||||
} else if(node->text != NULL && node->type == XMLLIB_NODE_COMMENT) {
|
||||
} else if(node->text != NULL && node->type == XL_NODE_COMMENT) {
|
||||
printf("<!--%s-->\n", node->text);
|
||||
}
|
||||
|
||||
|
|
@ -22,7 +22,7 @@ void recursive(xmllib_node_t* node, int indent) {
|
|||
n = n->next;
|
||||
}
|
||||
|
||||
if(node->name != NULL && node->type == XMLLIB_NODE_NODE) {
|
||||
if(node->name != NULL && node->type == XL_NODE_NODE) {
|
||||
for(i = 0; i < indent; i++) printf(" ");
|
||||
printf("</%s>\n", node->name);
|
||||
}
|
||||
|
|
@ -32,17 +32,17 @@ int main(int argc, char** argv) {
|
|||
int i;
|
||||
|
||||
for(i = 1; i < argc; i++) {
|
||||
xmllib_t* h = xmllib_open_file(argv[i]);
|
||||
xmllib_t* h = xl_open_file(argv[i]);
|
||||
if(h != NULL) {
|
||||
printf("%s:\n", argv[i]);
|
||||
if(xmllib_parse(h)) {
|
||||
if(xl_parse(h)) {
|
||||
if(h->root != NULL) recursive(h->root, INDENT);
|
||||
} else {
|
||||
int j;
|
||||
for(j = 0; j < INDENT; j++) printf(" ");
|
||||
printf("Parse error\n");
|
||||
}
|
||||
xmllib_close(h);
|
||||
xl_close(h);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue