I want to read an XML file into a char *buffer
using C.
What is the best way to do this?
How should I get started?
That's all...
example XML file:
Here is the source code:
#include
#include
#include
#include
#include
#include
char configReceive[6][80] = { " " };
//xml parsing
void ParsingXMLFile(char *filename) {
char *docname;
xmlDocPtr doc;
xmlNodePtr cur;
xmlChar *uri;
char config[6][80] = { "value1", "value2", "value3", "value4", "value5", "value6" };
int count = 0;
int count1 = 0;
docname = filename;
doc = xmlParseFile(docname);
cur = xmlDocGetRootElement(doc);
cur = cur->xmlChildrenNode;
while (cur != NULL) {
if ((!xmlStrcmp(cur->name, (const xmlChar *)"xmlConfig"))) {
uri = xmlGetProp(cur, (xmlChar *)config[count++]);
strcpy(configReceive[count1++], (char *)uri);
xmlFree(uri);
}
cur = cur->next;
}
count = 0;
count1 = 0;
xmlFreeDoc(doc);
}