[xml] xml file parsing error



Greetings all,

  I am just started to work with the xml parser interface, but I have a problem here.
I was trying to parsing a xml file and test if it is ok, I want to get the element names
of the tree, but it just output like this:
---
keyword: glyph
keyword: text
---

here is the main function:
int
main(void)
{
        xmlChar *key = NULL;
        xmlDocPtr glyphdb;
        xmlElement elem;
        xmlNodePtr cur;
        glyphdb = xmlReadFile("tutor.xml", NULL, 1);
        if (glyphdb == NULL ) {
                fprintf(stderr,"Document not parsed successfully. \n");
                return;
        }
        cur = xmlDocGetRootElement(glyphdb);
        while (cur != NULL) {
                key = (xmlChar*) cur->name;
                printf("keyword:%s\n", key);
                cur = cur->children;
        }
}

here's the xml file:
<glyph>
        <char codepoint="8AAA">
                <struct>left-right</struct>
                <left codepoint="2F94">
                        <hori>30-50</hori>
                        <verti>80-100</verti>
                </left>
                <right codepoint="514C">
                        <hori>10</hori>
                        <verti>100</verti>
                </right>
        </char>
</glyph>

Any suggetion  will be quite helpful, thx very much!

Deephay



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]