aspose file tools*
The moose likes XML and Related Technologies and the fly likes Parse Multiple Xml files with different structure Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Reply locked New topic
Author

Parse Multiple Xml files with different structure

Durga Roobini
Ranch Hand

Joined: Dec 19, 2013
Posts: 105
My Question is, i have two more xml files with different structure how i able parse that all single unit in servlets and also i send parsed xml data into client side based on its request please help me with sample code or any links
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18902
    
    8

You parse the first XML, then you parse the second XML. I don't see why it's a problem that the two XML documents have a different structure; you'd just have to write different code to parse them. Could you explain a bit more about why you are having a problem with this?
Durga Roobini
Ranch Hand

Joined: Dec 19, 2013
Posts: 105
if have 50 xml file means 50 times I want to parse it ha? instead I want to parse it once,here I want to access third party api eg like(Eventful,eventbrite) which are getting events based on location,date etc.i have two xml files from events site I have parse once in servlet it should be generic.
Durga Roobini
Ranch Hand

Joined: Dec 19, 2013
Posts: 105
I clearly tell my problem



Third party webservices (eventful,eventbrite,etc) ->{xml response} -> Server (serlvets) (parse all events at only once it should be generic) <->{request,response} -> Client(jsp,phonegap,smart tv etc)
E Armitage
Rancher

Joined: Mar 17, 2012
Posts: 892
    
    9
Durga Roobini wrote: if have 50 xml file means 50 times I want to parse it ha? instead I want to parse it once,here I want to access third party api eg like(Eventful,eventbrite) which are getting events based on location,date etc.i have two xml files from events site I have parse once in servlet it should be generic.


You are not making much sense here.
How many files do you want to parse? 50 or 2?
Do you have XSDs for those XML files?
Why do you want to parse those files? Are you just looking for certain values from them or do you have to read all the data in the files? What are you going to do with the data that you are reading from the files?
Forget about servlets for now. Parse the files in normal Java classes. You can then call those classes from the servlet.
What have you tried and where exactly are you stuck?
Durga Roobini
Ranch Hand

Joined: Dec 19, 2013
Posts: 105
I want to add xml file dynamically more than parsed xml could be generic
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42608
    
  65
If the XML files have different structure, then you need different code for handling them.


Ping & DNS - my free Android networking tools app
Durga Roobini
Ranch Hand

Joined: Dec 19, 2013
Posts: 105
Give some idea or samples to implement this one
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42608
    
  65
You already posted code for handling one server and its response in some other thread; what prevents you from doing that 3 times? (And maybe afterwards factoring out common parts into their own methods.)
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10266
    
168

Closing this one, since the topic starter already created another thread for discussing this same thing http://www.coderanch.com/t/626438/XML/Multiple-URL-access.

Durga, like you have been told before, please do not create multiple threads for the same questions.

[My Blog] [JavaRanch Journal]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Parse Multiple Xml files with different structure