Results 1 to 2 of 2
hi,
I am trying to extract data from the xml file using c coding. here is the sample code. this code gets compiled with errorfree. but the call back functions ...
- 02-11-2010 #1Just Joined!
- Join Date
- Feb 2010
- Posts
- 3
extracting data from a xml file using c in linux
hi,
I am trying to extract data from the xml file using c coding. here is the sample code. this code gets compiled with errorfree. but the call back functions start and end are not invoked. plz help me!!!
coding:
#include<stdio.h>
#include<string.h>
#include<expat.h>
void XMLCALL start(void *userData,const XML_Char *name,const XML_Char **atts);
void XMLCALL end(void *userData,const XML_Char *name);
void XMLCALL chard(void *ud,const XML_Char *s,int len);
int main()
{
XML_Parser p;
p=XML_ParserCreate("US-ASCII");
char *str,*str1;
str="<name att='2323' att2='545'>test value</name>";
int x=0;
x=strlen(str);
printf("%d",XML_Parse(p,str,x,1));
XML_SetUserData(p,str);
XML_SetElementHandler(p,start,end);
return 1;
}
void XMLCALL start(void *userData, const XML_Char *name,const XML_Char **atts)
{
printf("%s",name);
}
void XMLCALL end(void *userData,const XML_Char *name)
{
printf("End");
}
- 02-11-2010 #2Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 8,974
Please move this to the "Linux Programming & Scripting" forum. This one is for Red Hat / Fedora specific issues. Thanks.
Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!


Reply With Quote