Unable to parse XML using Libxml2 in C

oNothinGo

New Member
I'm new to libxml2 and started with an example, I don't understand why my sample code doesn't read some of the tags. I have my XML file in this way.\[code\]<ACCOUNTS><ACCOUNT NO="123"><STATE>GA</STATE><NAME>John</NAME></ACCOUNT><ACCOUNT NO="123"><STATE>GA</STATE><NAME>Burgess</NAME></ACCOUNT></ACCOUNTS>\[/code\]Here is my sample code : \[code\]void getReference (xmlDocPtr doc, xmlNodePtr cur) { xmlChar *uri; xmlChar *value; cur = cur->xmlChildrenNode; while (cur != NULL) { if ((!xmlStrcmp(cur->name, (const xmlChar *)"ACCOUNT"))) { uri = xmlGetProp(cur,(const xmlChar*) "NO"); printf("uri: %s\n", uri); xmlFree(uri); } cur = cur->next; } return;}\[/code\]When I debug I notice it goes to ACCOUNT tag for the first time and get the value and then move on to next ACCOUNT tag, ignoring STATE and NAME tags. What is wrong in this program and is this the correct approach?
 
Back
Top