tags:

views:

38

answers:

0

I'm using the MiniXML library to parse a XML file in C, however when i try to read the node's value it returns NULL.

Here's the code:

FILE *fp;
mxml_node_t *tree;

fp = fopen("test.xml", "r");
tree = mxmlLoadFile(NULL, fp, MXML_TEXT_CALLBACK);
fclose(fp);

mxml_node_t *node;
for(node = mxmlFindElement(tree, tree,"node",NULL, NULL,MXML_DESCEND);
     node != NULL;
     node = mxmlFindElement(node, tree,"node",NULL, NULL, MXML_DESCEND)) {
  printf("Text: %s\n", node->value.text.string);
}

The problem is that node->value.text.string is NULL. I've been reading the documentation and I don't know what im doing wrong. Has anybody run into this problem before?