From ahuja at aksysnetworks.com Thu Feb 22 01:27:15 2007 From: ahuja at aksysnetworks.com (Mandeep Ahuja) Date: Wed, 21 Feb 2007 16:27:15 -0800 Subject: [Expat-discuss] Event callbacks for every Tag Message-ID: Hi, I am new user of the expat library. My application requires different code to be run on different xml tags when they are found and on the fly. I have learned expat is event driven, but only one function is calledback on every tag found (endElement). My question is, can expat callback different functions based on tag found, meaning a unique callback for every tag. Is that possible? Please help me out any help is greatly appreciated thanks Mandeep From Mukesh.S at mphasis.com Thu Feb 22 06:31:44 2007 From: Mukesh.S at mphasis.com (Mukesh Kumar) Date: Thu, 22 Feb 2007 11:01:44 +0530 Subject: [Expat-discuss] Event callbacks for every Tag In-Reply-To: References: Message-ID: <7C83A8A6B56D3A478333B1DF47E18586650413@MPBABGEX01.corp.mphasis.com> The question is not clear dear. Regards, Mukesh Kumar, Sr.Software Engineer. Bangalore, -----Original Message----- From: expat-discuss-bounces at libexpat.org [mailto:expat-discuss-bounces at libexpat.org] On Behalf Of Mandeep Ahuja Sent: Thursday, February 22, 2007 5:57 AM To: expat-discuss at libexpat.org Subject: [Expat-discuss] Event callbacks for every Tag Hi, I am new user of the expat library. My application requires different code to be run on different xml tags when they are found and on the fly. I have learned expat is event driven, but only one function is calledback on every tag found (endElement). My question is, can expat callback different functions based on tag found, meaning a unique callback for every tag. Is that possible? Please help me out any help is greatly appreciated thanks Mandeep _______________________________________________ Expat-discuss mailing list Expat-discuss at libexpat.org http://mail.libexpat.org/mailman/listinfo/expat-discuss From regis.st-gelais at laubrass.com Thu Feb 22 13:21:29 2007 From: regis.st-gelais at laubrass.com (=?iso-8859-1?Q?R=E9gis_St-Gelais_=28Laubrass=29?=) Date: Thu, 22 Feb 2007 07:21:29 -0500 Subject: [Expat-discuss] Event callbacks for every Tag References: Message-ID: <003501c7567b$fbbfb6c0$6500a8c0@laubrasssag1> ----- Original Message ----- From: Mandeep Ahuja To: expat-discuss at libexpat.org Sent: Wednesday, February 21, 2007 7:27 PM Subject: [Expat-discuss] Event callbacks for every Tag Hi, I am new user of the expat library. My application requires different code to be run on different xml tags when they are found and on the fly. I have learned expat is event driven, but only one function is calledback on every tag found (endElement). My question is, can expat callback different functions based on tag found, meaning a unique callback for every tag. Is that possible? Please help me out You can do something like that: In the unic element_end callback, you multiplex your different callbacks based on the tag. static void XMLhndl_ElementEnd(void *userData, const char *strElement) { if (strcmp(strElement,"TAG1")==0) { // call your callback for TAG1 here return; } if (strcmp(strElement,"TAG2")==0) { // call your callback for TAG2 here return; } } Regis St-Gelais www.laubrass.com From regis.st-gelais at laubrass.com Thu Feb 22 13:54:23 2007 From: regis.st-gelais at laubrass.com (=?iso-8859-1?Q?R=E9gis_St-Gelais_=28Laubrass=29?=) Date: Thu, 22 Feb 2007 07:54:23 -0500 Subject: [Expat-discuss] Event callbacks for every Tag References: <003501c7567b$fbbfb6c0$6500a8c0@laubrasssag1> <7C83A8A6B56D3A478333B1DF47E18586650791@MPBABGEX01.corp.mphasis.com> Message-ID: <000c01c75680$94a6f200$6500a8c0@laubrasssag1> ----- Original Message ----- From: Mukesh Kumar To: R?gis St-Gelais (Laubrass) Sent: Thursday, February 22, 2007 7:36 AM Subject: RE: [Expat-discuss] Event callbacks for every Tag >You mean user defined functions or r u talking about performance or can you >tell me whether you are able to parse the xml file or not ? Mukesh, If I understood correctly your question was: can I call a different function for each tag ? Here is a more detailed sample code: static void XMLhndl_ElementEnd(void *userData, const char *strElement); static void XMLhndl_ElementEnd_Tag1(void *userData, const char *strElement); static void XMLhndl_ElementEnd_Tag2(void *userData, const char *strElement); static void XMLhndl_ElementEnd(void *userData, const char *strElement) // This is tha callback called by expat { if (strcmp(strElement,"TAG1")==0) { XMLhndl_ElementEnd_Tag1(userData,strElement); // Call your own fonction when TAG1 is found return; } if (strcmp(strElement,"TAG2")==0) { XMLhndl_ElementEnd_Tag2(userData,strElement); // Call your own fonction when TAG2 is found return; } } static void XMLhndl_ElementEnd_Tag1(void *userData, const char *strElement) { // do some thing with tag 1 data } static void XMLhndl_ElementEnd_Tag2(void *userData, const char *strElement) { // do some thing with tag 2 data } If this does not do what you want, then I don't undestand your question. Regis St-Gelais www.laubrass.com -----Original Message----- From: expat-discuss-bounces at libexpat.org [mailto:expat-discuss-bounces at libexpat.org] On Behalf Of R?gis St-Gelais (Laubrass) Sent: Thursday, February 22, 2007 5:51 PM To: Mandeep Ahuja; expat-discuss at libexpat.org Subject: Re: [Expat-discuss] Event callbacks for every Tag ----- Original Message ----- From: Mandeep Ahuja To: expat-discuss at libexpat.org Sent: Wednesday, February 21, 2007 7:27 PM Subject: [Expat-discuss] Event callbacks for every Tag > Hi, I am new user of the expat library. My application requires different > code to be run on different xml tags when they are found and on the fly. I > have learned expat is event >driven, but only one function is calledback > on every tag found (endElement). My question is, can expat callback > different functions based on tag found, meaning a unique >callback for > every tag. Is that possible? > Please help me out > >You can do something like that: >In the unic element_end callback, you multiplex your different callbacks >based on the tag. > > { > if (strcmp(strElement,"TAG1")==0) > { > // call your callback for TAG1 here > return; > } > > if (strcmp(strElement,"TAG2")==0) > { > // call your callback for TAG2 here > return; > } > >} >Regis St-Gelais >www.laubrass.com From ali at mental.com Thu Feb 22 14:09:13 2007 From: ali at mental.com (Albrecht Fritzsche) Date: Thu, 22 Feb 2007 14:09:13 +0100 Subject: [Expat-discuss] Expat-discuss Digest, Vol 83, Issue 1 In-Reply-To: References: Message-ID: <45DD95F9.9020709@mental.com> expat-discuss-request at libexpat.org wrote: > Date: Wed, 21 Feb 2007 16:27:15 -0800 > From: "Mandeep Ahuja" > Subject: [Expat-discuss] Event callbacks for every Tag > To: expat-discuss at libexpat.org > Message-ID: > Content-Type: text/plain; charset="us-ascii" > > Hi, I am new user of the expat library. My application requires different code to be run on different xml tags when they are found and on the fly. I have learned expat is event driven, but only one function is calledback on every tag found (endElement). My question is, can expat callback different functions based on tag found, meaning a unique callback for every tag. Is that possible? > Please help me out Hi Madeep, the feature you are asking for is not part of expat. If you think about it it wouldn't even make sense - who knows, ie how can expat know, what tags you have in your application. Thatswhy expat calls on every tag (regardless its name) *one* callback and passing to the name of the tag (plus the attributes). This is generic and works for every application. To achieve what you want it is easy to add application-specific code to that on_stat_element handler such that for every tag name an application-specific callback will be called. (I am, for instance, using a STL map for the mapping from tag name to the callback std::map > ) But that is nothing expat lib could do for you since, as said, this is application-specific. Hope it helps Ali From regis.st-gelais at laubrass.com Thu Feb 22 17:45:42 2007 From: regis.st-gelais at laubrass.com (=?iso-8859-1?Q?R=E9gis_St-Gelais_=28Laubrass=29?=) Date: Thu, 22 Feb 2007 11:45:42 -0500 Subject: [Expat-discuss] Fw: Event callbacks for every Tag Message-ID: <00ab01c756a0$e649f0b0$6500a8c0@laubrasssag1> Private email I got from Mandeep Ahuja. Just to let the list know that his issue is resolved. From: Mandeep Ahuja To: "R?gis St-Gelais (Laubrass)" Sent: Thursday, February 22, 2007 11:27 AM Subject: Re: [Expat-discuss] Event callbacks for every Tag thats awesome, it does the job thanks a lot guys mandeep >R?gis St-Gelais (Laubrass) wrote: > > > ----- Original Message ----- > > *From:* Mandeep Ahuja > *To:* expat-discuss at libexpat.org > *Sent:* Wednesday, February 21, 2007 7:27 PM > *Subject:* [Expat-discuss] Event callbacks for every Tag > > Hi, I am new user of the expat library. My application requires > different code to be run on different xml tags when they are found > and on the fly. I have learned expat is event driven, but only one > function is calledback on every tag found (endElement). My > question is, can expat callback different functions based on tag > found, meaning a unique callback for every tag. Is that possible? > Please help me out > > You can do something like that: > In the unic element_end callback, you multiplex your different > callbacks based on the tag. > > static void XMLhndl_ElementEnd(void *userData, const char *strElement) > { > if (strcmp(strElement,"TAG1")==0) > { > // call your callback for TAG1 here > return; > } > > if (strcmp(strElement,"TAG2")==0) > { > // call your callback for TAG2 here > return; > } > > } > > Regis St-Gelais > www.laubrass.com