windows平台上,C语言,用libxml2解析xml文件遇到的有关问题

windows平台上,C语言,用libxml2解析xml文件遇到的问题
C/C++ code


#include <stdio.h> 
#include <string.h> 
#include <stdlib.h> 
#include <libxml/xmlmemory.h> 
#include <libxml/parser.h> 

void parseStory (xmlDocPtr doc, xmlNodePtr cur) { 
    xmlChar *key; 
    cur = cur->xmlChildrenNode; 
    while (cur != NULL) { 
        if ((!xmlStrcmp(cur->name, (const xmlChar *)"keyword"))) { 
            key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); 
            printf("keyword: %s\n", key); 
            xmlFree(key); 
        } 
        cur = cur->next; 
    } 
    return;
}

static void parseDoc() { 
    xmlDocPtr doc ;          [color=#FF0000]//在这边doc的地址是x0cccccccc[/color]
    xmlNodePtr cur;          [color=#FF0000]//在这边cur的地址也是x0cccccccc[/color]
    doc = xmlParseFile("D:\\test.xml");    [color=#FF0000]//在这边doc的地址是x0ffffffff[/color]     
    if (doc == NULL ) { 
        printf("Document not parsed successfully. \n"); 
        return; 
    } 
    cur = xmlDocGetRootElement(doc);        [color=#FF0000]//程序运行到这儿就出错了[/color]
    if (cur == NULL) { 
        fprintf(stderr,"empty document\n"); 
        xmlFreeDoc(doc); 
        return; 
    } 
    if (xmlStrcmp(cur->name, (const xmlChar *) "story")) { 
        printf("document of the wrong type, root node != story"); 
        xmlFreeDoc(doc); 
        return; 
    } 
    cur = cur->xmlChildrenNode; 
    while (cur != NULL) { 
        if ((!xmlStrcmp(cur->name, (const xmlChar *)"storyinfo"))){ 
        parseStory (doc, cur); 
        } 
    cur = cur->next; 
    } 
    xmlFreeDoc(doc); 
    return; 
} 

int main() { 

    parseDoc (); 
    return (1); 
}





这段程序是在网上找的示例程序,编译链接都正确也没有警告,但是就是运行不起来,单步之后,发现指针的地址很奇怪,不知这段程序问题到底出在哪里,请高手指教!感激不尽啊!





------解决方案--------------------
不知道,帮你顶吧。