Best approach to parse multiple xml files using SAX Parser

Common bugs/problems with the Android SDK the Emulator and the ADT-Plugin.

Best approach to parse multiple xml files using SAX Parser

Postby iappdev » Sun May 23, 2010 12:36 pm

Hi,

I am writing an application where I need to parse multiple XML files received from server as a http response. For now, I have written one class for parsing one XML file. But I am not happy about writing one class for handling/parsing one XML response. Can I combine classes that I have written for XML parsing into one class ? Is it a good idea ? Would it hamper performance as If I combine classes, it would have lot of tags and every XML will be tested against all tags
?

I am using SAXParser for parsing XML response.

Please help.
iappdev
Freshman
Freshman
 
Posts: 9
Joined: Mon Apr 12, 2010 12:13 pm
Location: Pune India

Top

Re: Best approach to parse multiple xml files using SAX Pars

Postby padde » Sun May 23, 2010 2:06 pm

So instead of creating one handler class per XML file type you want to create one big handler that can parse all types of xml files you are dealing with? If thats the case this shouldn't be a problem i guess.. but if you need to check the order or occurences of specific tags as some kind of validity check for your XML files this one big class could get realy hard to read and to understand.

Personally i would go for one handler per XML file type for better readability, maintainability and expandability.. but
if its all carved in stones and there are no bugs and no future changes to be expected you could go for one big handler.
padde
Master Developer
Master Developer
 
Posts: 443
Joined: Wed Apr 08, 2009 4:52 pm

Re: Best approach to parse multiple xml files using SAX Pars

Postby iappdev » Sun May 23, 2010 2:53 pm

Thanks Padde.

I agree that writing one big class could result into future problems. But at the same time I was unsure about whether approach of one class per xml is correct or not. Thanks for your input. Will go ahead with one class per xml.
iappdev
Freshman
Freshman
 
Posts: 9
Joined: Mon Apr 12, 2010 12:13 pm
Location: Pune India

Top

Return to SDK/ADT/Emulator Problems

Who is online

Users browsing this forum: Exabot [Bot] and 2 guests