Bookmark Topic Watch Topic
  • New Topic

Parse Multiple Xml files with different structure

 
Durga Roobini
Ranch Hand
Posts: 107
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
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
Sheriff
Pie
Posts: 20161
23
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
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
Posts: 107
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
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
Posts: 107
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
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
Posts: 989
9
  • 2
  • Mark post as helpful
  • send pies
  • Report post to moderator
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
Posts: 107
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
I want to add xml file dynamically more than parsed xml could be generic
 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
If the XML files have different structure, then you need different code for handling them.
 
Durga Roobini
Ranch Hand
Posts: 107
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
Give some idea or samples to implement this one
 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
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
Pie
Posts: 10444
227
IntelliJ IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
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.
 
It is sorta covered in the JavaRanch Style Guide.
    Bookmark Topic Watch Topic
  • New Topic