Thank you indeed.
Here is the xml sample from xmlsoft.org
Code:
<?xml version="1.0"?>
<story>
<storyinfo>
<author>John Fleck</author>
<datewritten>June 2, 2002</datewritten>
<keyword>example keyword</keyword>
</storyinfo>
<body>
<headline>This is the headline</headline>
<para>This is the body text.</para>
</body>
</story>
Here is the code portion from xmlsoft.org with my modification to display all elements inside:
Code:
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);
}
*/
key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
printf("Element:Name %s\n", cur->name);
printf("Element Value: %s\n", key);
cur = cur->next;
}
return;
}
Here is the output:
What's wrong with my code?
[/img]