#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <mcheck.h>
#include "mxml.h"
void find_node()
{
FILE *fp;
mxml_node_t *tree = NULL;
fp = fopen("test.xml", "r");
tree = mxmlLoadFile(NULL, fp, NULL);
fclose(fp);
mxml_node_t *node;
const char *name, *prog;
/* 使用中文 */
for (node = mxmlFindElement(tree, tree, "node", NULL, NULL, MXML_DESCEND);
node != NULL;
node = mxmlFindElement(node, tree, "node", NULL, NULL, MXML_DESCEND))
{
name = mxmlElementGetAttr(node, "name");
prog = mxmlElementGetAttr(node, "prog");
//printf("name=%s, prog=%s \n", name, prog);
}
mxmlDelete(tree);
}
int main()
{
int i=10000;
//setenv("MALLOC_TRACE", "mymemory.log", 1);
//mtrace();
while(i--)
find_node();
//muntrace();
return 0;
}
|