Hi
I am working in unix platform. I am very new to xml parsing.. I downloaded libxml2-2.6.31.tar.gz and i installed successfully. my program is like this
1 #include <stdio.h>
2 #include <libxml/parser.h>
3 #include <libxml/tree.h>
4
5 static void print_element_names(xmlNode * a_node)
6 {
7 xmlNode *cur_node = NULL;
8
9 for (cur_node = a_node; cur_node; cur_node =
cur_node->next) {
10 if (cur_node->type == XML_ELEMENT_NODE) {
11 printf("node type: Element, name: %s\n",
cur_node->name);
12 }
13 print_element_names(cur_node->children);
14 }
15 }
16
17 int main(int argc, char **argv)
18 {
19 xmlDoc *doc = NULL;
20 xmlNode *root_element = NULL;
21
22 if (argc != 2) return(1);
23
24 LIBXML_TEST_VERSION // Macro to check API for match with
// the DLL we are using
25
26 /*parse the file and get the DOM */
27 if (doc = xmlReadFile(argv[1], NULL, 0)) == NULL){
28 printf("error: could not parse file %s\n", argv[1]);
29 exit(-1);
30 }
31
32 /*Get the root element node */
33 root_element = xmlDocGetRootElement(doc);
34 print_element_names(root_element);
35 xmlFreeDoc(doc); // free document
36 xmlCleanupParser(); // Free globals
37 return 0;
38 }
and make it compile as cc parser.cc. then i got undefined reference error as follows.
/tmp/ccEMs4sY.o: In function `example3Func':
parse.c
.text+0x2c): undefined reference to `xmlReadMemory'
parse.c
.text+0x67): undefined reference to `xmlFreeDoc'
/tmp/ccEMs4sY.o: In function `main':
parse.c
.text+0x89): undefined reference to `xmlCheckVersion'
parse.c
.text+0xe3): undefined reference to `xmlCleanupParser'
parse.c
.text+0xe8): undefined reference to `xmlMemoryDump'
collect2: ld returned 1 exit status
can u help me to solve this plssss
Thankz in advance..