#include #include #include #include #include static void print_names(xmlNode *node) { xmlNode *cur_node = NULL; for (cur_node = node; cur_node; cur_node = cur_node->next) { if (cur_node->type == XML_ELEMENT_NODE) { if ( strcmp(cur_node->name, "Student") == 0 ) { xmlAttr *prop = NULL; if ( (prop = xmlHasProp(cur_node, "Name")) != NULL ) { printf("%s\n", prop->children->content); } } } print_names(cur_node->children); } } const char *buffer = "\n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" "\n"; int main() { xmlDoc *doc = NULL; xmlNode *root = NULL; doc = xmlReadMemory(buffer, strlen(buffer), NULL, NULL, 0); if ( doc != NULL ) { root = xmlDocGetRootElement(doc); print_names(root); xmlFreeDoc(doc); } xmlCleanupParser(); return 0; }